diff --git a/daemon/lightningd.c b/daemon/lightningd.c index 55986dd0d..a2b613453 100644 --- a/daemon/lightningd.c +++ b/daemon/lightningd.c @@ -84,6 +84,9 @@ static void config_register_opts(struct lightningd_state *dstate) opt_register_arg("--min-commit-fee", opt_set_u64, opt_show_u64, &dstate->config.commitment_fee_min, "Minimum satoshis to accept for commitment transaction fee"); + opt_register_arg("--bitcoind-poll", opt_set_u32, opt_show_u32, + &dstate->config.poll_seconds, + "Seconds between polling for new transactions"); } static void default_config(struct config *config) @@ -110,6 +113,8 @@ static void default_config(struct config *config) /* Don't accept less than double the current standard fee. */ config->commitment_fee_min = 10000; + + config->poll_seconds = 30; } static struct lightningd_state *lightningd_state(void) diff --git a/daemon/lightningd.h b/daemon/lightningd.h index 782e4f4a2..2bef158cd 100644 --- a/daemon/lightningd.h +++ b/daemon/lightningd.h @@ -31,6 +31,9 @@ struct config { /* How little are we prepared to have them pay? */ u64 commitment_fee_min; + + /* How long (seconds) between polling bitcoind. */ + u32 poll_seconds; }; /* Here's where the global variables hide! */ diff --git a/daemon/test/test.sh b/daemon/test/test.sh index 90a3371a4..dc5bc72a1 100755 --- a/daemon/test/test.sh +++ b/daemon/test/test.sh @@ -31,8 +31,8 @@ LCLI2="../daemon/lightning-cli --lightning-dir=$DIR2" trap "echo Results in $DIR1 and $DIR2" EXIT mkdir $DIR1 $DIR2 -$PREFIX1 ../daemon/lightningd --log-level=debug --lightning-dir=$DIR1 > $REDIR1 & -$PREFIX2 ../daemon/lightningd --log-level=debug --lightning-dir=$DIR2 > $REDIR2 & +$PREFIX1 ../daemon/lightningd --log-level=debug --bitcoind-poll=1 --lightning-dir=$DIR1 > $REDIR1 & +$PREFIX2 ../daemon/lightningd --log-level=debug --bitcoind-poll=1 --lightning-dir=$DIR2 > $REDIR2 & i=0 while ! $LCLI1 getlog | grep Hello; do @@ -65,8 +65,8 @@ $LCLI2 getpeers | grep STATE_OPEN_WAITING_THEIRANCHOR # Now make it pass anchor. $CLI generate 3 -# FIXME: Speed this up! -sleep 30 +# They poll every second, so give them time to process. +sleep 2 $LCLI1 getpeers | grep STATE_NORMAL_HIGHPRIO $LCLI2 getpeers | grep STATE_NORMAL_LOWPRIO diff --git a/daemon/watch.c b/daemon/watch.c index 69c42fa0a..dc56467cc 100644 --- a/daemon/watch.c +++ b/daemon/watch.c @@ -226,7 +226,8 @@ static void start_poll_transactions(struct lightningd_state *dstate) void setup_watch_timer(struct lightningd_state *dstate) { - init_timeout(&watch_timeout, 30, start_poll_transactions, dstate); + init_timeout(&watch_timeout, dstate->config.poll_seconds, + start_poll_transactions, dstate); /* Run once immediately, in case there are issues. */ start_poll_transactions(dstate); }