]> Untitled Git - bdk/commitdiff
esplora: also fix the gap limit check in the async client
authorAntoine Poinsot <darosior@protonmail.com>
Mon, 20 Nov 2023 11:00:31 +0000 (12:00 +0100)
committerAntoine Poinsot <darosior@protonmail.com>
Fri, 24 Nov 2023 11:21:14 +0000 (12:21 +0100)
crates/esplora/src/async_ext.rs

index 653a80f030cd421cb56293a0a60c76596a02f4aa..b41050533e357c54c32976b1373f14938ac2a434 100644 (file)
@@ -259,7 +259,13 @@ impl EsploraAsyncExt for esplora_client::AsyncClient {
                     }
                 }
 
-                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.");
+                let past_gap_limit = if let Some(i) = last_active_index {
+                    last_index > i.saturating_add(stop_gap as u32)
+                } else {
+                    last_index >= stop_gap as u32
+                };
+                if past_gap_limit {
                     break;
                 }
             }