add uptime and bytes sent/recvd to peer struct and getPeers

This commit is contained in:
Arceliar 2018-05-18 20:41:02 -05:00
parent fdb826578f
commit 5c0636eb3d
2 changed files with 21 additions and 8 deletions

View file

@ -10,6 +10,7 @@ import "net/url"
import "sort"
import "strings"
import "strconv"
import "sync/atomic"
import "time"
// TODO? Make all of this JSON
@ -322,6 +323,9 @@ func (a *admin) getData_getPeers() []admin_nodeInfo {
info := admin_nodeInfo{
{"IP", net.IP(addr[:]).String()},
{"port", fmt.Sprint(port)},
{"uptime", fmt.Sprint(time.Since(p.firstSeen))},
{"bytesSent", fmt.Sprint(atomic.LoadUint64(&p.bytesSent))},
{"bytesRecvd", fmt.Sprint(atomic.LoadUint64(&p.bytesRecvd))},
}
peerInfos = append(peerInfos, info)
}