diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c index ea7be3271..967b25f88 100644 --- a/lightningd/chaintopology.c +++ b/lightningd/chaintopology.c @@ -24,7 +24,8 @@ static void try_extend_tip(struct chain_topology *topo); static void next_topology_timer(struct chain_topology *topo) { /* This takes care of its own lifetime. */ - notleak(new_reltimer(topo->timers, topo, topo->poll_time, + notleak(new_reltimer(topo->timers, topo, + time_from_sec(topo->poll_seconds), try_extend_tip, topo)); } @@ -331,7 +332,8 @@ static void start_fee_estimate(struct chain_topology *topo) static void next_updatefee_timer(struct chain_topology *topo) { /* This takes care of its own lifetime. */ - notleak(new_reltimer(topo->timers, topo, topo->poll_time, + notleak(new_reltimer(topo->timers, topo, + time_from_sec(topo->poll_seconds), start_fee_estimate, topo)); } @@ -720,16 +722,16 @@ struct chain_topology *new_topology(struct lightningd *ld, struct log *log) topo->override_fee_rate = NULL; topo->bitcoind = new_bitcoind(topo, ld, log); topo->wallet = ld->wallet; + topo->poll_seconds = 30; return topo; } void setup_topology(struct chain_topology *topo, struct timers *timers, - struct timerel poll_time, u32 first_blocknum) + u32 first_blocknum) { memset(&topo->feerate, 0, sizeof(topo->feerate)); topo->timers = timers; - topo->poll_time = poll_time; topo->first_blocknum = first_blocknum; diff --git a/lightningd/chaintopology.h b/lightningd/chaintopology.h index 4f7d11f63..ef0fff067 100644 --- a/lightningd/chaintopology.h +++ b/lightningd/chaintopology.h @@ -93,7 +93,7 @@ struct chain_topology { unsigned int first_blocknum; /* How often to poll. */ - struct timerel poll_time; + u32 poll_seconds; /* The bitcoind. */ struct bitcoind *bitcoind; @@ -150,7 +150,7 @@ void broadcast_tx(struct chain_topology *topo, struct chain_topology *new_topology(struct lightningd *ld, struct log *log); void setup_topology(struct chain_topology *topology, struct timers *timers, - struct timerel poll_time, u32 first_channel_block); + u32 first_channel_block); void begin_topology(struct chain_topology *topo); diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 557f042a6..448cd805f 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -395,7 +395,6 @@ int main(int argc, char *argv[]) /* Initialize block topology (does its own transaction) */ setup_topology(ld->topology, &ld->timers, - ld->config.poll_time, blockheight); /* Create RPC socket (if any) */ diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 90da02582..25223be46 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -51,9 +51,6 @@ struct config { u32 fee_base; s32 fee_per_satoshi; - /* How long between polling bitcoind. */ - struct timerel poll_time; - /* How long between changing commit and sending COMMIT message. */ struct timerel commit_time; diff --git a/lightningd/options.c b/lightningd/options.c index 1f08669ae..9356a891d 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -360,9 +360,6 @@ static void config_register_opts(struct lightningd *ld) opt_register_arg("--max-htlc-expiry", opt_set_u32, opt_show_u32, &ld->config.max_htlc_expiry, "Maximum number of blocks to accept an HTLC before expiry"); - opt_register_arg("--bitcoind-poll", opt_set_time, opt_show_time, - &ld->config.poll_time, - "Time between polling for new transactions"); opt_register_arg("--commit-time", opt_set_time, opt_show_time, &ld->config.commit_time, "Time after changes before sending out COMMIT"); @@ -447,6 +444,9 @@ static void dev_register_opts(struct lightningd *ld) opt_register_noarg("--dev-allow-localhost", opt_set_bool, &ld->dev_allow_localhost, "Announce and allow announcments for localhost address"); + opt_register_arg("--dev-bitcoind-poll", opt_set_u32, opt_show_u32, + &ld->topology->poll_seconds, + "Time between polling for new transactions"); } #endif @@ -480,9 +480,6 @@ static const struct config testnet_config = { /* Don't lock up channel for more than 5 days. */ .max_htlc_expiry = 5 * 6 * 24, - /* How often to bother bitcoind. */ - .poll_time = TIME_FROM_SEC(10), - /* Send commit 10msec after receiving; almost immediately. */ .commit_time = TIME_FROM_MSEC(10), @@ -544,9 +541,6 @@ static const struct config mainnet_config = { /* Don't lock up channel for more than 5 days. */ .max_htlc_expiry = 5 * 6 * 24, - /* How often to bother bitcoind. */ - .poll_time = TIME_FROM_SEC(30), - /* Send commit 10msec after receiving; almost immediately. */ .commit_time = TIME_FROM_MSEC(10), diff --git a/lightningd/test/run-find_my_path.c b/lightningd/test/run-find_my_path.c index 3f5e3152c..e58ce373e 100644 --- a/lightningd/test/run-find_my_path.c +++ b/lightningd/test/run-find_my_path.c @@ -96,7 +96,7 @@ void setup_jsonrpc(struct lightningd *ld UNNEEDED, const char *rpc_filename UNNE /* Generated stub for setup_topology */ void setup_topology(struct chain_topology *topology UNNEEDED, struct timers *timers UNNEEDED, - struct timerel poll_time UNNEEDED, u32 first_channel_block UNNEEDED) + u32 first_channel_block UNNEEDED) { fprintf(stderr, "setup_topology called!\n"); abort(); } /* Generated stub for subd_shutdown */ void subd_shutdown(struct subd *subd UNNEEDED, unsigned int seconds UNNEEDED) diff --git a/tests/utils.py b/tests/utils.py index aca114753..15e5a8821 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -19,7 +19,6 @@ BITCOIND_CONFIG = { LIGHTNINGD_CONFIG = { - "bitcoind-poll": "1s", "log-level": "debug", "cltv-delta": 6, "cltv-final": 5, @@ -282,6 +281,7 @@ class LightningD(TailableProc): f.write(seed) if DEVELOPER: self.opts['dev-broadcast-interval'] = 1000 + self.opts['dev-bitcoind-poll'] = 1 # lightningd won't announce non-routable addresses by default. self.opts['dev-allow-localhost'] = None self.prefix = 'lightningd-%d' % (node_id)