diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c index 916ee4550..b956508c6 100644 --- a/lightningd/chaintopology.c +++ b/lightningd/chaintopology.c @@ -191,6 +191,13 @@ static void rebroadcast_txs(struct chain_topology *topo) } tal_free(cleanup_ctx); + /* Free explicitly in case we were called because a block came in. + * Then set a new timer 30-60 seconds away */ + tal_free(topo->rebroadcast_timer); + topo->rebroadcast_timer = new_reltimer(topo->ld->timers, topo, + time_from_sec(30 + pseudorand(30)), + rebroadcast_txs, topo); + /* Let this do the dirty work. */ txs->cursor = (size_t)-1; broadcast_remainder(topo->bitcoind, true, "", txs); @@ -1162,6 +1169,7 @@ struct chain_topology *new_topology(struct lightningd *ld, struct log *log) topo->root = NULL; topo->sync_waiters = tal(topo, struct list_head); topo->extend_timer = NULL; + topo->rebroadcast_timer = NULL; topo->stopping = false; list_head_init(topo->sync_waiters); diff --git a/lightningd/chaintopology.h b/lightningd/chaintopology.h index faddc4916..4c7ce628a 100644 --- a/lightningd/chaintopology.h +++ b/lightningd/chaintopology.h @@ -133,7 +133,7 @@ struct chain_topology { struct bitcoind *bitcoind; /* Timers we're running. */ - struct oneshot *extend_timer, *updatefee_timer; + struct oneshot *extend_timer, *updatefee_timer, *rebroadcast_timer; /* Bitcoin transactions we're broadcasting */ struct outgoing_tx_map *outgoing_txs;