mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
lightningd: rebroadcast all pending txs each 30-60 seconds.
We also do it on every block, but since bitcoind can't always be counted to rebroadcast for us, we might as well be aggressive! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
3754e283f8
commit
62fa91e23b
2 changed files with 9 additions and 1 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue