kopia lustrzana https://github.com/bugout-dev/moonstream
Getting polygon_block_latest_label_moonworm_alpha for status db
rodzic
1b5bbcdb29
commit
5da6f8d838
|
@ -5,6 +5,7 @@ type PingResponse struct {
|
|||
}
|
||||
|
||||
type BlockLatestResponse struct {
|
||||
EthereumBlockLatest uint64 `json:"ethereum_block_latest"`
|
||||
PolygonBlockLatest uint64 `json:"polygon_block_latest"`
|
||||
EthereumBlockLatest uint64 `json:"ethereum_block_latest"`
|
||||
PolygonBlockLatest uint64 `json:"polygon_block_latest"`
|
||||
PolygonBlockLatestLabelsMoonwormAlpha uint64 `json:"polygon_block_latest_label_moonworm_alpha"`
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
@ -45,8 +47,9 @@ func (es *extendedServer) blocksLatestRoute(w http.ResponseWriter, req *http.Req
|
|||
}
|
||||
|
||||
blockLatest = BlockLatestResponse{
|
||||
EthereumBlockLatest: blockNumbers[0],
|
||||
PolygonBlockLatest: blockNumbers[1],
|
||||
EthereumBlockLatest: blockNumbers[0],
|
||||
PolygonBlockLatest: blockNumbers[1],
|
||||
PolygonBlockLatestLabelsMoonwormAlpha: blockNumbers[2],
|
||||
}
|
||||
|
||||
json.NewEncoder(w).Encode(blockLatest)
|
||||
|
|
Ładowanie…
Reference in New Issue