Skip to content

Commit 4ee86b5

Browse files
committed
Bound sync loops in lightning-transaction-sync
If we start syncing from an electrum or esplora server and find that the chain moved during our sync, we reset and start fresh. However, if that happens repeatedly, we probably shouldn't just spin forever. Here we give up after five attempts and just hope we can sync properly later.
1 parent 311ad94 commit 4ee86b5

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lightning-transaction-sync/src/electrum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ where
102102
let mut tip_header = tip_notification.header;
103103
let mut tip_height = tip_notification.height as u32;
104104

105-
loop {
105+
for _ in 0..5 {
106106
let pending_registrations = self.queue.lock().unwrap().process_queues(&mut sync_state);
107107
let tip_is_new = Some(tip_header.block_hash()) != sync_state.last_sync_hash;
108108

lightning-transaction-sync/src/esplora.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ where
106106

107107
let mut tip_hash = maybe_await!(self.client.get_tip_hash())?;
108108

109-
loop {
109+
for _ in 0..5 {
110110
let pending_registrations = self.queue.lock().unwrap().process_queues(&mut sync_state);
111111
let tip_is_new = Some(tip_hash) != sync_state.last_sync_hash;
112112

0 commit comments

Comments
 (0)