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:
parent
32faaaf418
commit
ba6b79ae0e
1 changed files with 3 additions and 2 deletions
|
|
@ -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"])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue