lnd+rpcserver: allow customized timeout in ConnectPeer

This commit is contained in:
yyforyongyu
2020-08-25 12:54:31 +08:00
parent ef38b12fda
commit 469aba9282
8 changed files with 754 additions and 668 deletions

View File

@@ -496,6 +496,14 @@ var connectCommand = cli.Command{
Category: "Peers",
Usage: "Connect to a remote lnd peer.",
ArgsUsage: "<pubkey>@host",
Description: `
Connect to a peer using its <pubkey> and host.
A custom timeout on the connection is supported. For instance, to timeout
the connection request in 30 seconds, use the following:
lncli connect <pubkey>@host --timeout 30s
`,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "perm",
@@ -503,6 +511,13 @@ var connectCommand = cli.Command{
"connect to the target peer.\n" +
" If not, the call will be synchronous.",
},
cli.DurationFlag{
Name: "timeout",
Usage: "The connection timeout value for current request. " +
"Valid uints are {ms, s, m, h}.\n" +
"If not set, the global connection " +
"timeout value (default to 120s) is used.",
},
},
Action: actionDecorator(connectPeer),
}
@@ -524,8 +539,9 @@ func connectPeer(ctx *cli.Context) error {
Host: splitAddr[1],
}
req := &lnrpc.ConnectPeerRequest{
Addr: addr,
Perm: ctx.Bool("perm"),
Addr: addr,
Perm: ctx.Bool("perm"),
Timeout: uint64(ctx.Duration("timeout").Seconds()),
}
lnid, err := client.ConnectPeer(ctxb, req)