Skip to content

Commit

Permalink
esplora: fix incorrect gap limit check in blocking client
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
darosior committed Nov 20, 2023
1 parent 46d39be commit 65e1d36
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/esplora/src/blocking_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 65e1d36

Please sign in to comment.