package orm
import (
+ "database/sql"
"encoding/json"
"errors"
"fmt"
return nil, errors.New("fail to look up status")
}
- avgLantencyMS := 0
+ avgLantencyMS := uint64(0)
if n.AvgLantencyMS.Valid {
- avgLantencyMS = n.AvgLantencyMS.Int64
+ avgLantencyMS = uint64(n.AvgLantencyMS.Int64)
}
return json.Marshal(&struct {
PublicKey string `json:"publickey"`
Address string `json:"address"`
BestHeight uint64 `json:"best_height"`
- AvgLantencyMS int64 `json:"avg_lantency_ms"`
+ AvgLantencyMS uint64 `json:"avg_lantency_ms"`
LatestDailyUptimeMinutes uint64 `json:"latest_daily_uptime_minutes"`
Status string `json:"status"`
UpdatedAt time.Time `json:"updated_at"`
latestLiveness := ormNodeLivenesses[0]
lantencyMS := ping.Nanoseconds() / 1000
if lantencyMS != 0 {
- latestLiveness.AvgLantencyMS = sql.NullInt64{
- Int64: (latestLiveness.AvgLantencyMS.Int64*int64(latestLiveness.PongTimes) + lantencyMS) / int64(latestLiveness.PongTimes+1),
+ ormNode.AvgLantencyMS = sql.NullInt64{
+ Int64: (ormNode.AvgLantencyMS.Int64*int64(latestLiveness.PongTimes) + lantencyMS) / int64(latestLiveness.PongTimes+1),
Valid: true,
}
}