diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c index 767de73ab..212f67f0b 100644 --- a/lightningd/chaintopology.c +++ b/lightningd/chaintopology.c @@ -745,14 +745,14 @@ struct chain_topology *new_topology(struct lightningd *ld, struct log *log) void setup_topology(struct chain_topology *topo, struct timers *timers, - u32 first_blocknum) + u32 min_blockheight, u32 max_blockheight) { memset(&topo->feerate, 0, sizeof(topo->feerate)); topo->timers = timers; /* FIXME(cdecker) Actually load this from DB */ - topo->min_blockheight = first_blocknum; - topo->max_blockheight = first_blocknum; + topo->min_blockheight = min_blockheight; + topo->max_blockheight = max_blockheight; /* Make sure bitcoind is started, and ready */ wait_for_bitcoind(topo->bitcoind); diff --git a/lightningd/chaintopology.h b/lightningd/chaintopology.h index ce63bc4ff..b6021984a 100644 --- a/lightningd/chaintopology.h +++ b/lightningd/chaintopology.h @@ -150,9 +150,8 @@ void broadcast_tx(struct chain_topology *topo, const char *err)); struct chain_topology *new_topology(struct lightningd *ld, struct log *log); -void setup_topology(struct chain_topology *topology, - struct timers *timers, - u32 first_channel_block); +void setup_topology(struct chain_topology *topology, struct timers *timers, + u32 min_blockheight, u32 max_blockheight); void begin_topology(struct chain_topology *topo); diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index bdffd4e25..d520d0f1c 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -306,7 +306,7 @@ void notify_new_block(struct lightningd *ld, int main(int argc, char *argv[]) { struct lightningd *ld; - u32 blockheight, first_block; + u32 min_blockheight, max_blockheight; setup_locale(); daemon_setup(argv[0], log_backtrace_print, log_backtrace_exit); @@ -388,24 +388,22 @@ int main(int argc, char *argv[]) /* Get the blockheight we are currently at, UINT32_MAX is used to signal * an unitialized wallet and that we should start off of bitcoind's * current height */ - wallet_blocks_heights(ld->wallet, UINT32_MAX, &first_block, &blockheight); + wallet_blocks_heights(ld->wallet, UINT32_MAX, &min_blockheight, &max_blockheight); /* If we were asked to rescan from an absolute height (--rescan < 0) - * then just go there. Otherwise take compute the diff to our current - * height, lowerbounded by 0. */ + * then just go there. Otherwise compute the diff to our current height, + * lowerbounded by 0. */ if (ld->config.rescan < 0) - blockheight = -ld->config.rescan; - else if (blockheight < (u32)ld->config.rescan) - blockheight = 0; - else if (blockheight != UINT32_MAX) - blockheight -= ld->config.rescan; + max_blockheight = -ld->config.rescan; + else if (max_blockheight < (u32)ld->config.rescan) + max_blockheight = 0; + else if (max_blockheight != UINT32_MAX) + max_blockheight -= ld->config.rescan; db_commit_transaction(ld->wallet->db); /* Initialize block topology (does its own transaction) */ - setup_topology(ld->topology, - &ld->timers, - blockheight); + setup_topology(ld->topology, &ld->timers, min_blockheight, max_blockheight); /* Create RPC socket (if any) */ setup_jsonrpc(ld, ld->rpc_filename); diff --git a/lightningd/test/run-find_my_path.c b/lightningd/test/run-find_my_path.c index 38c630371..06208b423 100644 --- a/lightningd/test/run-find_my_path.c +++ b/lightningd/test/run-find_my_path.c @@ -101,9 +101,8 @@ void setup_color_and_alias(struct lightningd *ld UNNEEDED) void setup_jsonrpc(struct lightningd *ld UNNEEDED, const char *rpc_filename UNNEEDED) { fprintf(stderr, "setup_jsonrpc called!\n"); abort(); } /* Generated stub for setup_topology */ -void setup_topology(struct chain_topology *topology UNNEEDED, - struct timers *timers UNNEEDED, - u32 first_channel_block UNNEEDED) +void setup_topology(struct chain_topology *topology UNNEEDED, struct timers *timers UNNEEDED, + u32 min_blockheight UNNEEDED, u32 max_blockheight UNNEEDED) { fprintf(stderr, "setup_topology called!\n"); abort(); } /* Generated stub for subd_shutdown */ void subd_shutdown(struct subd *subd UNNEEDED, unsigned int seconds UNNEEDED)