(rw http.ResponseWriter, r *http.Request)
| 413 | } |
| 414 | |
| 415 | func (a *explorerAPI) GetHighestBlockV3(rw http.ResponseWriter, r *http.Request) { |
| 416 | vars := mux.Vars(r) |
| 417 | |
| 418 | dbID, err := a.getDBID(vars) |
| 419 | if err != nil { |
| 420 | sendResponse(400, false, err, nil, rw) |
| 421 | return |
| 422 | } |
| 423 | |
| 424 | count, height, block, err := a.service.getHighestBlockV2(dbID) |
| 425 | if err == ErrNotFound { |
| 426 | // try to add subscription |
| 427 | err = a.service.subscribe(dbID, "oldest") |
| 428 | if err == nil { |
| 429 | count, height, block, err = a.service.getHighestBlockV2(dbID) |
| 430 | if err != nil { |
| 431 | sendResponse(500, false, err, nil, rw) |
| 432 | return |
| 433 | } |
| 434 | } else { |
| 435 | sendResponse(400, false, err, nil, rw) |
| 436 | return |
| 437 | } |
| 438 | } else if err != nil { |
| 439 | sendResponse(500, false, err, nil, rw) |
| 440 | return |
| 441 | } |
| 442 | |
| 443 | op := newPaginationFromReq(r) |
| 444 | |
| 445 | sendResponse(200, true, "", a.formatBlockV3(count, height, block, op), rw) |
| 446 | } |
| 447 | |
| 448 | func (a *explorerAPI) formatBlock(height int32, b *types.Block) (res map[string]interface{}) { |
| 449 | queries := make([]string, 0, len(b.Acks)) |
nothing calls this directly
no test coverage detected