MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / GetBlockByCountV3

Method GetBlockByCountV3

sqlchain/observer/api.go:253–285  ·  view source on GitHub ↗
(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

251}
252
253func (a *explorerAPI) GetBlockByCountV3(rw http.ResponseWriter, r *http.Request) {
254 vars := mux.Vars(r)
255
256 dbID, err := a.getDBID(vars)
257 if err != nil {
258 sendResponse(400, false, err, nil, rw)
259 return
260 }
261
262 countStr := vars["count"]
263 if countStr == "" {
264 sendResponse(400, false, "empty count", nil, rw)
265 return
266 }
267
268 countNumber, err := strconv.ParseInt(countStr, 10, 32)
269 if err != nil {
270 sendResponse(400, false, err, nil, rw)
271 return
272 }
273
274 count := int32(countNumber)
275
276 height, block, err := a.service.getBlockByCount(dbID, count)
277 if err != nil {
278 sendResponse(500, false, err, nil, rw)
279 return
280 }
281
282 op := newPaginationFromReq(r)
283
284 sendResponse(200, true, "", a.formatBlockV3(count, height, block, op), rw)
285}
286
287func (a *explorerAPI) GetBlockByHeight(rw http.ResponseWriter, r *http.Request) {
288 vars := mux.Vars(r)

Callers

nothing calls this directly

Calls 5

getDBIDMethod · 0.95
formatBlockV3Method · 0.95
newPaginationFromReqFunction · 0.85
getBlockByCountMethod · 0.80
sendResponseFunction · 0.70

Tested by

no test coverage detected