Skip to content

Commit 16ff8ad

Browse files
committed
fix(electrum): improve tx validation and gap limit scanning
1 parent 90b8956 commit 16ff8ad

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

crates/electrum/src/bdk_electrum_client.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
263263
let mut txs_to_validate = Vec::new();
264264

265265
loop {
266+
if unused_spk_count >= stop_gap {
267+
break;
268+
}
269+
266270
let spks = (0..batch_size)
267271
.map_while(|_| spks_with_expected_txids.next())
268272
.collect::<Vec<_>>();
@@ -277,9 +281,6 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
277281
for ((spk_index, spk), spk_history) in spks.into_iter().zip(spk_histories) {
278282
if spk_history.is_empty() {
279283
unused_spk_count = unused_spk_count.saturating_add(1);
280-
if unused_spk_count >= stop_gap {
281-
break;
282-
}
283284
} else {
284285
last_active_index = Some(spk_index);
285286
unused_spk_count = 0;

crates/electrum/tests/test_electrum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ fn test_check_fee_calculation() -> anyhow::Result<()> {
880880

881881
#[test]
882882
pub fn test_sync_performance() -> anyhow::Result<()> {
883-
const EXPECTED_MAX_SYNC_TIME: Duration = Duration::from_secs(5);
883+
const EXPECTED_MAX_SYNC_TIME: Duration = Duration::from_secs(15);
884884
const NUM_ADDRESSES: usize = 1000;
885885

886886
let env = TestEnv::new()?;

0 commit comments

Comments
 (0)