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:
carla
2020-03-13 09:15:49 +02:00
parent 54089febd6
commit 4c48d0361d
6 changed files with 991 additions and 812 deletions

View File

@@ -1335,7 +1335,13 @@ var listPeersCommand = cli.Command{
Name: "listpeers",
Category: "Peers",
Usage: "List all active, currently connected peers.",
Action: actionDecorator(listPeers),
Flags: []cli.Flag{
cli.BoolFlag{
Name: "list_errors",
Usage: "list a full set of most recent errors for the peer",
},
},
Action: actionDecorator(listPeers),
}
func listPeers(ctx *cli.Context) error {
@@ -1343,7 +1349,11 @@ func listPeers(ctx *cli.Context) error {
client, cleanUp := getClient(ctx)
defer cleanUp()
req := &lnrpc.ListPeersRequest{}
// By default, we display a single error on the cli. If the user
// specifically requests a full error set, then we will provide it.
req := &lnrpc.ListPeersRequest{
LatestError: !ctx.IsSet("list_errors"),
}
resp, err := client.ListPeers(ctxb, req)
if err != nil {
return err