Getting polygon_block_latest_label_moonworm_alpha for status db

pull/582/head
kompotkot 2022-04-13 16:29:21 +00:00
rodzic 1b5bbcdb29
commit 5da6f8d838
2 zmienionych plików z 10 dodań i 6 usunięć

Wyświetl plik

@ -7,4 +7,5 @@ type PingResponse struct {
type BlockLatestResponse struct {
EthereumBlockLatest uint64 `json:"ethereum_block_latest"`
PolygonBlockLatest uint64 `json:"polygon_block_latest"`
PolygonBlockLatestLabelsMoonwormAlpha uint64 `json:"polygon_block_latest_label_moonworm_alpha"`
}

Wyświetl plik

@ -20,8 +20,10 @@ func (es *extendedServer) blocksLatestRoute(w http.ResponseWriter, req *http.Req
var blockNumbers []uint64
var blockLatest BlockLatestResponse
rows, err := es.db.Query(`(SELECT block_number FROM ethereum_blocks ORDER BY block_number DESC LIMIT 1)
UNION
(SELECT block_number FROM polygon_blocks ORDER BY block_number DESC LIMIT 1)`)
UNION ALL
(SELECT block_number FROM polygon_blocks ORDER BY block_number DESC LIMIT 1)
UNION ALL
(SELECT block_number FROM polygon_labels WHERE label = 'moonworm-alpha' ORDER BY block_number DESC LIMIT 1)`)
if err != nil {
log.Printf("An error occurred during sql operation: %s", err)
http.Error(w, "Internal server error", http.StatusInternalServerError)
@ -47,6 +49,7 @@ func (es *extendedServer) blocksLatestRoute(w http.ResponseWriter, req *http.Req
blockLatest = BlockLatestResponse{
EthereumBlockLatest: blockNumbers[0],
PolygonBlockLatest: blockNumbers[1],
PolygonBlockLatestLabelsMoonwormAlpha: blockNumbers[2],
}
json.NewEncoder(w).Encode(blockLatest)