`ip` varchar(128) NOT NULL DEFAULT '',
`port` smallint unsigned NOT NULL DEFAULT '0',
`best_height` int(11) DEFAULT '0',
- `avg_lantency_ms` int(11) DEFAULT NULL,
+ `avg_rtt_ms` int(11) DEFAULT NULL,
`latest_daily_uptime_minutes` int(11) DEFAULT '0',
`status` tinyint(1) NOT NULL DEFAULT '0',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
IP string
Port uint16
BestHeight uint64
- AvgLantencyMS sql.NullInt64
+ AvgRttMS sql.NullInt64
LatestDailyUptimeMinutes uint64
Status uint8
CreatedAt time.Time `json:"alias"`
return nil, errors.New("fail to look up status")
}
- avgLantencyMS := uint64(0)
- if n.AvgLantencyMS.Valid {
- avgLantencyMS = uint64(n.AvgLantencyMS.Int64)
+ avgRttMS := uint64(0)
+ if n.AvgRttMS.Valid {
+ avgRttMS = uint64(n.AvgRttMS.Int64)
}
return json.Marshal(&struct {
PublicKey string `json:"publickey"`
Address string `json:"address"`
BestHeight uint64 `json:"best_height"`
- AvgLantencyMS uint64 `json:"avg_lantency_ms"`
+ AvgRttMS uint64 `json:"avg_rtt_ms"`
LatestDailyUptimeMinutes uint64 `json:"latest_daily_uptime_minutes"`
Status string `json:"status"`
UpdatedAt time.Time `json:"updated_at"`
PublicKey: n.PublicKey,
Address: fmt.Sprintf("%s:%d", n.IP, n.Port),
BestHeight: n.BestHeight,
- AvgLantencyMS: avgLantencyMS,
+ AvgRttMS: avgRttMS,
LatestDailyUptimeMinutes: n.LatestDailyUptimeMinutes,
Status: status,
UpdatedAt: time.Now(),
return m.db.Save(ormNode).Error
}
+func parseRemoteAddr(remoteAddr string) (string, uint16, error) {
+ host, portStr, err := net.SplitHostPort(remoteAddr)
+ if err != nil {
+ return "", 0, err
+ }
+
+ port, err := strconv.Atoi(portStr)
+ if err != nil {
+ return "", 0, err
+ }
+
+ return host, uint16(port), nil
+}
+
func (m *monitor) processDialResults(peerList []*p2p.Peer) error {
var ormNodes []*orm.Node
if err := m.db.Model(&orm.Node{}).Find(&ormNodes).Error; err != nil {
}
}
-func parseRemoteAddr(remoteAddr string) (string, uint16, error) {
- host, portStr, err := net.SplitHostPort(remoteAddr)
- if err != nil {
- return "", 0, err
- }
-
- port, err := strconv.Atoi(portStr)
- if err != nil {
- return "", 0, err
- }
-
- return host, uint16(port), nil
-}
-
func (m *monitor) processPeerInfo(dbTx *gorm.DB, peerInfo *peers.PeerInfo) error {
ip, port, err := parseRemoteAddr(peerInfo.RemoteAddr)
if err != nil {
latestLiveness := ormNodeLivenesses[0]
lantencyMS := ping.Nanoseconds() / 1000000
if lantencyMS != 0 {
- ormNode.AvgLantencyMS = sql.NullInt64{
- Int64: (ormNode.AvgLantencyMS.Int64*int64(latestLiveness.PongTimes) + lantencyMS) / int64(latestLiveness.PongTimes+1),
+ ormNode.AvgRttMS = sql.NullInt64{
+ Int64: (ormNode.AvgRttMS.Int64*int64(latestLiveness.PongTimes) + lantencyMS) / int64(latestLiveness.PongTimes+1),
Valid: true,
}
}