Browse Source

lightningd/options.c: Add option for setting how long to keep trying bitcoin-cli command.

pull/2938/head
ZmnSCPxj 6 years ago
committed by Christian Decker
parent
commit
bb301040e4
  1. 11
      doc/lightningd-config.5
  2. 5
      doc/lightningd-config.5.txt
  3. 11
      lightningd/bitcoind.c
  4. 4
      lightningd/bitcoind.h
  5. 6
      lightningd/options.c

11
doc/lightningd-config.5

@ -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\&.

5
doc/lightningd-config.5.txt

@ -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.

11
lightningd/bitcoind.c

@ -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;

4
lightningd/bitcoind.h

@ -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;
};

6
lightningd/options.c

@ -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");

Loading…
Cancel
Save