Skip to content

Commit c8f9833

Browse files
authored
Merge pull request lightningdevkit#4612 from TheBlueMatt/2026-05-esplora-sync-timeout
Bound sync loops in lightning-transaction-sync
2 parents 39434df + 1c7fcb7 commit c8f9833

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

lightning-transaction-sync/src/electrum.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ impl<L: Logger> ElectrumSyncClient<L> {
9696
let mut tip_header = tip_notification.header;
9797
let mut tip_height = tip_notification.height as u32;
9898

99-
loop {
99+
for i in 0..100 {
100+
if i >= 10 {
101+
log_debug!(self.logger, "Giving up trying to sync transactions after 10 attempts.");
102+
sync_state.pending_sync = true;
103+
return Err(TxSyncError::Failed);
104+
}
105+
100106
let pending_registrations = self.queue.lock().unwrap().process_queues(&mut sync_state);
101107
let tip_is_new = Some(tip_header.block_hash()) != sync_state.last_sync_hash;
102108

lightning-transaction-sync/src/esplora.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,13 @@ impl<L: Logger> EsploraSyncClient<L> {
100100

101101
let mut tip_hash = maybe_await!(self.client.get_tip_hash())?;
102102

103-
loop {
103+
for i in 0..100 {
104+
if i >= 10 {
105+
log_debug!(self.logger, "Giving up trying to sync transactions after 10 attempts.");
106+
sync_state.pending_sync = true;
107+
return Err(TxSyncError::Failed);
108+
}
109+
104110
let pending_registrations = self.queue.lock().unwrap().process_queues(&mut sync_state);
105111
let tip_is_new = Some(tip_hash) != sync_state.last_sync_hash;
106112

0 commit comments

Comments
 (0)