multi: add flap count and last flap time to listpeers
This commit is contained in:
6 files changed
+964
-750
No files matched your search
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user