1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-06-17 04:50:02 +02:00

src/server.go: in check_api_v2() use utils.JsonGetInt64() to safely get a int64 value from json.

If json contains "nil" value, the type assertion will fail. JsonGetInt64() will in that case return "0"
This commit is contained in:
Henrik Hautakoski 2020-06-24 14:41:13 +02:00
parent 32faaaf418
commit ba6b79ae0e

View file

@ -9,6 +9,7 @@ import (
"./pid"
"./haproxy"
"./eosapi"
"./utils"
"github.com/firstrow/tcp_server"
"github.com/pborman/getopt/v2"
)
@ -55,9 +56,9 @@ func check_api_v2(p eosapi.ReqParams, offset int64) (haproxy.HealthCheckStatus,
for _, v := range health.Health {
if v.Name == "Elasticsearch" {
es_block = (int64) (v.Data["last_indexed_block"].(float64))
es_block = utils.JsonGetInt64(v.Data["last_indexed_block"])
} else if v.Name == "NodeosRPC" {
node_block = (int64) (v.Data["head_block_num"].(float64))
node_block = utils.JsonGetInt64(v.Data["head_block_num"])
}
}