mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
lightningd/chaintopology: stop callbacks rearming once topology stopped.
Otherwise we get very upset when the plugins go away. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
31f439760f
commit
ad31a49455
2 changed files with 13 additions and 1 deletions
|
@ -438,6 +438,8 @@ static void update_feerates(struct bitcoind *bitcoind,
|
|||
static void start_fee_estimate(struct chain_topology *topo)
|
||||
{
|
||||
topo->updatefee_timer = NULL;
|
||||
if (topo->stopping)
|
||||
return;
|
||||
/* Once per new block head, update fee estimates. */
|
||||
bitcoind_estimate_fees(topo->bitcoind, NUM_FEERATES, update_feerates,
|
||||
topo);
|
||||
|
@ -937,6 +939,8 @@ static void get_new_block(struct bitcoind *bitcoind,
|
|||
static void try_extend_tip(struct chain_topology *topo)
|
||||
{
|
||||
topo->extend_timer = NULL;
|
||||
if (topo->stopping)
|
||||
return;
|
||||
bitcoind_getrawblockbyheight(topo->bitcoind, topo->tip->height + 1,
|
||||
get_new_block, topo);
|
||||
}
|
||||
|
@ -1066,6 +1070,7 @@ struct chain_topology *new_topology(struct lightningd *ld, struct log *log)
|
|||
topo->feerate_uninitialized = true;
|
||||
topo->root = NULL;
|
||||
topo->sync_waiters = tal(topo, struct list_head);
|
||||
topo->stopping = false;
|
||||
list_head_init(topo->sync_waiters);
|
||||
|
||||
return topo;
|
||||
|
@ -1158,6 +1163,8 @@ check_chain(struct bitcoind *bitcoind, const char *chain,
|
|||
static void retry_check_chain(struct chain_topology *topo)
|
||||
{
|
||||
topo->bitcoind->checkchain_timer = NULL;
|
||||
if (topo->stopping)
|
||||
return;
|
||||
bitcoind_getchaininfo(topo->bitcoind, false, check_chain, topo);
|
||||
}
|
||||
|
||||
|
@ -1194,9 +1201,11 @@ void begin_topology(struct chain_topology *topo)
|
|||
|
||||
void stop_topology(struct chain_topology *topo)
|
||||
{
|
||||
/* Stop timers from re-arming. */
|
||||
topo->stopping = true;
|
||||
|
||||
/* Remove timers while we're cleaning up plugins. */
|
||||
tal_free(topo->bitcoind->checkchain_timer);
|
||||
tal_free(topo->extend_timer);
|
||||
tal_free(topo->updatefee_timer);
|
||||
}
|
||||
|
||||
|
|
|
@ -126,6 +126,9 @@ struct chain_topology {
|
|||
/* The number of headers known to the bitcoin backend at startup. Not
|
||||
* updated after the initial check. */
|
||||
u32 headercount;
|
||||
|
||||
/* Are we stopped? */
|
||||
bool stopping;
|
||||
};
|
||||
|
||||
/* Information relevant to locating a TX in a blockchain. */
|
||||
|
|
Loading…
Add table
Reference in a new issue