lnd: list active channels in response to listpeers
cmd
This commit is contained in:
parent
e61a03a372
commit
914159cb87
18
rpcserver.go
18
rpcserver.go
@ -222,8 +222,10 @@ func (r *rpcServer) ListPeers(ctx context.Context,
|
||||
|
||||
for _, serverPeer := range serverPeers {
|
||||
// TODO(roasbeef): add a snapshot method which grabs peer read mtx
|
||||
|
||||
lnID := hex.EncodeToString(serverPeer.lightningID[:])
|
||||
peer := &lnrpc.Peer{
|
||||
LightningId: hex.EncodeToString(serverPeer.lightningID[:]),
|
||||
LightningId: lnID,
|
||||
PeerId: serverPeer.id,
|
||||
Address: serverPeer.conn.RemoteAddr().String(),
|
||||
Inbound: serverPeer.inbound,
|
||||
@ -231,6 +233,20 @@ func (r *rpcServer) ListPeers(ctx context.Context,
|
||||
BytesSent: atomic.LoadUint64(&serverPeer.bytesSent),
|
||||
}
|
||||
|
||||
chanSnapshots := serverPeer.ChannelSnapshots()
|
||||
peer.Channels = make([]*lnrpc.ActiveChannel, 0, len(chanSnapshots))
|
||||
for _, chanSnapshot := range chanSnapshots {
|
||||
channel := &lnrpc.ActiveChannel{
|
||||
RemoteId: lnID,
|
||||
ChannelPoint: chanSnapshot.ChannelPoint.String(),
|
||||
Capacity: int64(chanSnapshot.Capacity),
|
||||
LocalBalance: int64(chanSnapshot.LocalBalance),
|
||||
RemoteBalance: int64(chanSnapshot.RemoteBalance),
|
||||
NumUpdates: chanSnapshot.NumUpdates,
|
||||
}
|
||||
peer.Channels = append(peer.Channels, channel)
|
||||
}
|
||||
|
||||
resp.Peers = append(resp.Peers, peer)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user