mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-08 16:44:22 +01:00
lightningd/options.c: Add option for setting how long to keep trying bitcoin-cli command.
This commit is contained in:
committed by
Christian Decker
parent
e737fe72d6
commit
bb301040e4
@@ -1,13 +1,13 @@
|
||||
'\" t
|
||||
.\" Title: lightningd-config
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
|
||||
.\" Date: 04/11/2019
|
||||
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
||||
.\" Date: 06/30/2019
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "LIGHTNINGD\-CONFIG" "5" "04/11/2019" "\ \&" "\ \&"
|
||||
.TH "LIGHTNINGD\-CONFIG" "5" "06/30/2019" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
@@ -121,6 +121,11 @@ The bitcoind(1) RPC host to connect to\&.
|
||||
The bitcoind(1) RPC port to connect to\&.
|
||||
.RE
|
||||
.PP
|
||||
\fBbitcoin\-retry\-timeout\fR=\fISECONDS\fR
|
||||
.RS 4
|
||||
Number of seconds to keep trying a bitcoin\-cli(1) command\&. If the command keeps failing after this time, exit with a fatal error\&.
|
||||
.RE
|
||||
.PP
|
||||
\fBrescan\fR=\fIBLOCKS\fR
|
||||
.RS 4
|
||||
Number of blocks to rescan from the current head, or absolute blockheight if negative\&. This is only needed if something goes badly wrong\&.
|
||||
|
||||
@@ -88,6 +88,11 @@ Bitcoin control options:
|
||||
*bitcoin-rpcport*='PORT'::
|
||||
The bitcoind(1) RPC port to connect to.
|
||||
|
||||
*bitcoin-retry-timeout*='SECONDS'::
|
||||
Number of seconds to keep trying a bitcoin-cli(1) command.
|
||||
If the command keeps failing after this time, exit with a
|
||||
fatal error.
|
||||
|
||||
*rescan*='BLOCKS'::
|
||||
Number of blocks to rescan from the current head, or absolute blockheight
|
||||
if negative. This is only needed if something goes badly wrong.
|
||||
|
||||
@@ -154,13 +154,17 @@ static void bcli_failure(struct bitcoind *bitcoind,
|
||||
bitcoind->first_error_time = time_mono();
|
||||
|
||||
t = timemono_between(time_mono(), bitcoind->first_error_time);
|
||||
if (time_greater(t, time_from_sec(60)))
|
||||
fatal("%s exited %u (after %u other errors) '%.*s'",
|
||||
if (time_greater(t, time_from_sec(bitcoind->retry_timeout)))
|
||||
fatal("%s exited %u (after %u other errors) '%.*s'; "
|
||||
"we have been retrying command for "
|
||||
"--bitcoin-retry-timeout=%"PRIu64" seconds; "
|
||||
"bitcoind setup or our --bitcoin-* configs broken?",
|
||||
bcli_args(tmpctx, bcli),
|
||||
exitstatus,
|
||||
bitcoind->error_count,
|
||||
(int)bcli->output_bytes,
|
||||
bcli->output);
|
||||
bcli->output,
|
||||
bitcoind->retry_timeout);
|
||||
|
||||
log_unusual(bitcoind->log,
|
||||
"%s exited with status %u",
|
||||
@@ -930,6 +934,7 @@ struct bitcoind *new_bitcoind(const tal_t *ctx,
|
||||
}
|
||||
bitcoind->shutdown = false;
|
||||
bitcoind->error_count = 0;
|
||||
bitcoind->retry_timeout = 60;
|
||||
bitcoind->rpcuser = NULL;
|
||||
bitcoind->rpcpass = NULL;
|
||||
bitcoind->rpcconnect = NULL;
|
||||
|
||||
@@ -59,6 +59,10 @@ struct bitcoind {
|
||||
/* Ignore results, we're shutting down. */
|
||||
bool shutdown;
|
||||
|
||||
/* How long to keep trying to contact bitcoind
|
||||
* before fatally exiting. */
|
||||
u64 retry_timeout;
|
||||
|
||||
/* Passthrough parameters for bitcoin-cli */
|
||||
char *rpcuser, *rpcpass, *rpcconnect, *rpcport;
|
||||
};
|
||||
|
||||
@@ -858,6 +858,12 @@ void register_opts(struct lightningd *ld)
|
||||
opt_register_arg("--bitcoin-rpcport", opt_set_talstr, NULL,
|
||||
&ld->topology->bitcoind->rpcport,
|
||||
"bitcoind RPC port");
|
||||
opt_register_arg("--bitcoin-retry-timeout",
|
||||
opt_set_u64, opt_show_u64,
|
||||
&ld->topology->bitcoind->retry_timeout,
|
||||
"how long to keep trying to contact bitcoind "
|
||||
"before fatally exiting");
|
||||
|
||||
opt_register_arg("--pid-file=<file>", opt_set_talstr, opt_show_charp,
|
||||
&ld->pidfile,
|
||||
"Specify pid file");
|
||||
|
||||
Reference in New Issue
Block a user