mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
rpcserver: display the number of satoshis sent/recv'd and ping time in ListPeers
This commit is contained in:
parent
3c5a23b2c1
commit
780203e287
19
rpcserver.go
19
rpcserver.go
@ -652,6 +652,22 @@ func (r *rpcServer) ListPeers(ctx context.Context,
|
||||
for _, serverPeer := range serverPeers {
|
||||
// TODO(roasbeef): add a snapshot method which grabs peer read mtx
|
||||
|
||||
var (
|
||||
satSent int64
|
||||
satRecv int64
|
||||
)
|
||||
|
||||
// In order to display the total number of satoshis of outbound
|
||||
// (sent) and inbound (recv'd) satoshis that have been
|
||||
// transported through this peer, we'll sum up the sent/recv'd
|
||||
// values for each of the active channels we ahve with the
|
||||
// peer.
|
||||
chans := serverPeer.ChannelSnapshots()
|
||||
for _, c := range chans {
|
||||
satSent += int64(c.TotalSatoshisSent)
|
||||
satRecv += int64(c.TotalSatoshisReceived)
|
||||
}
|
||||
|
||||
nodePub := serverPeer.addr.IdentityKey.SerializeCompressed()
|
||||
peer := &lnrpc.Peer{
|
||||
PubKey: hex.EncodeToString(nodePub),
|
||||
@ -660,6 +676,9 @@ func (r *rpcServer) ListPeers(ctx context.Context,
|
||||
Inbound: serverPeer.inbound,
|
||||
BytesRecv: atomic.LoadUint64(&serverPeer.bytesReceived),
|
||||
BytesSent: atomic.LoadUint64(&serverPeer.bytesSent),
|
||||
SatSent: satSent,
|
||||
SatRecv: satRecv,
|
||||
PingTime: serverPeer.PingTime(),
|
||||
}
|
||||
|
||||
resp.Peers = append(resp.Peers, peer)
|
||||
|
Loading…
Reference in New Issue
Block a user