mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-22 20:17:51 +01:00
lnrpc+lncli: display peer errors in listpeers
This change adds a set of errors to the peer struct returned by list peers. A latest error boolean is added to allow for more succinct default lncli responses.
This commit is contained in:
27
rpcserver.go
27
rpcserver.go
@@ -2459,6 +2459,33 @@ func (r *rpcServer) ListPeers(ctx context.Context,
|
||||
Features: features,
|
||||
}
|
||||
|
||||
var peerErrors []interface{}
|
||||
|
||||
// If we only want the most recent error, get the most recent
|
||||
// error from the buffer and add it to our list of errors if
|
||||
// it is non-nil. If we want all the stored errors, simply
|
||||
// add the full list to our set of errors.
|
||||
if in.LatestError {
|
||||
latestErr := serverPeer.errorBuffer.Latest()
|
||||
if latestErr != nil {
|
||||
peerErrors = []interface{}{latestErr}
|
||||
}
|
||||
} else {
|
||||
peerErrors = serverPeer.errorBuffer.List()
|
||||
}
|
||||
|
||||
// Add the relevant peer errors to our response.
|
||||
for _, error := range peerErrors {
|
||||
tsError := error.(*timestampedError)
|
||||
|
||||
rpcErr := &lnrpc.TimestampedError{
|
||||
Timestamp: uint64(tsError.timestamp.Unix()),
|
||||
Error: tsError.error.Error(),
|
||||
}
|
||||
|
||||
peer.Errors = append(peer.Errors, rpcErr)
|
||||
}
|
||||
|
||||
resp.Peers = append(resp.Peers, peer)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user