From 65e1d36eae02429691d9c06af0f00e1d613a52dc Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Mon, 20 Nov 2023 10:34:10 +0100 Subject: [PATCH] esplora: fix incorrect gap limit check in blocking client The gap limit was checked such as if the last_index was not None but the last_active_index was, we'd consider having reached it. But the last_index is never None for this check. This effectively made it so the gap limit was always 1: if the first address isn't used last_active_index will be None and we'd return immediately. Fix this by avoiding error-prone Option comparisons and correctly checking we've reached the gap limit before breaking out of the loop. --- crates/esplora/src/blocking_ext.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/esplora/src/blocking_ext.rs b/crates/esplora/src/blocking_ext.rs index 9c259d5835..af013a3b02 100644 --- a/crates/esplora/src/blocking_ext.rs +++ b/crates/esplora/src/blocking_ext.rs @@ -250,7 +250,8 @@ impl EsploraExt for esplora_client::BlockingClient { } } - if last_index > last_active_index.map(|i| i.saturating_add(stop_gap as u32)) { + let last_index = last_index.expect("Must be set since handles wasn't empty."); + if last_index > last_active_index.unwrap_or(0) + stop_gap as u32 { break; } }