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

Method GetBlockByHeight

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

Source from the content-addressed store, hash-verified

285}
286
287func (a *explorerAPI) GetBlockByHeight(rw http.ResponseWriter, r *http.Request) {
288 vars := mux.Vars(r)
289
290 dbID, err := a.getDBID(vars)
291 if err != nil {
292 sendResponse(400, false, err, nil, rw)
293 return
294 }
295
296 heightStr := vars["height"]
297 if heightStr == "" {
298 sendResponse(400, false, "empty height", nil, rw)
299 return
300 }
301
302 heightNumber, err := strconv.ParseInt(heightStr, 10, 32)
303 if err != nil {
304 sendResponse(400, false, err, nil, rw)
305 return
306 }
307
308 height := int32(heightNumber)
309
310 _, block, err := a.service.getBlockByHeight(dbID, height)
311 if err != nil {
312 sendResponse(500, false, err, nil, rw)
313 return
314 }
315
316 sendResponse(200, true, "", a.formatBlock(height, block), rw)
317}
318
319func (a *explorerAPI) GetBlockByHeightV3(rw http.ResponseWriter, r *http.Request) {
320 vars := mux.Vars(r)

Callers

nothing calls this directly

Calls 4

getDBIDMethod · 0.95
formatBlockMethod · 0.95
getBlockByHeightMethod · 0.80
sendResponseFunction · 0.70

Tested by

no test coverage detected