Skip to content

Commit 18bd329

Browse files
committed
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.
1 parent 9e681b3 commit 18bd329

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/esplora/src/blocking_ext.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,13 @@ impl EsploraExt for esplora_client::BlockingClient {
250250
}
251251
}
252252

253-
if last_index > last_active_index.map(|i| i.saturating_add(stop_gap as u32)) {
253+
let last_index = last_index.expect("Must be set since handles wasn't empty.");
254+
let past_gap_limit = if let Some(i) = last_active_index {
255+
last_index > i.saturating_add(stop_gap as u32)
256+
} else {
257+
last_index >= stop_gap as u32
258+
};
259+
if past_gap_limit {
254260
break;
255261
}
256262
}

0 commit comments

Comments
 (0)