OSDN Git Service

fix
authorHAOYUatHZ <haoyu@protonmail.com>
Sun, 1 Sep 2019 06:50:43 +0000 (14:50 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Sun, 1 Sep 2019 06:50:43 +0000 (14:50 +0800)
toolbar/precog/monitor/stats.go

index 4a57da3..13c8818 100644 (file)
@@ -147,17 +147,17 @@ func (m *monitor) processPeerInfo(dbTx *gorm.DB, peerInfo *peers.PeerInfo) error
        // update latest liveness
        latestLiveness := ormNodeLivenesses[0]
        rttMS := ping.Nanoseconds() / 1000000
+       if rttMS > 0 && rttMS < 2000 {
+               ormNode.Status = common.NodeHealthyStatus
+       } else if rttMS > 2000 {
+               ormNode.Status = common.NodeCongestedStatus
+       }
        if rttMS != 0 {
                ormNode.AvgRttMS = sql.NullInt64{
                        Int64: (ormNode.AvgRttMS.Int64*int64(latestLiveness.PongTimes) + rttMS) / int64(latestLiveness.PongTimes+1),
                        Valid: true,
                }
        }
-       if rttMS > 0 && rttMs < 2000 {
-               ormNode.Status = common.NodeHealthyStatus
-       } else if rttMS > 2000 {
-               ormNode.Status = common.NodeCongestedStatus
-       }
        latestLiveness.PongTimes += 1
        if peerInfo.Height != 0 {
                latestLiveness.BestHeight = peerInfo.Height