multi: add flap count and last flap time to listpeers

This commit is contained in:
carla committed 2020-09-08 15:01:06 +02:00
1 parent 6cf66aea47
commit e2c0604657
6 files changed
+964 -750

No files matched your search

+24
View File
@@ -2701,6 +2701,30 @@ func (r *rpcServer) ListPeers(ctx context.Context,
rpcPeer.Errors = append(rpcPeer.Errors, rpcErr)
}
// If the server has started, we can query the event store
// for our peer's flap count. If we do so when the server has
// not started, the request will block.
if r.server.Started() {
vertex, err := route.NewVertexFromBytes(nodePub[:])
if err != nil {
return nil, err
}
flap, ts, err := r.server.chanEventStore.FlapCount(
vertex,
)
if err != nil {
return nil, err
}
// If our timestamp is non-nil, we have values for our
// peer's flap count, so we set them.
if ts != nil {
rpcPeer.FlapCount = int32(flap)
rpcPeer.LastFlapNs = ts.UnixNano()
}
}
resp.Peers = append(resp.Peers, rpcPeer)
}