Skip to content

Commit

Permalink
retain all scanned ranges boundary blocks in the wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar-Pepper committed Jan 16, 2025
1 parent 312f5c8 commit 23f4442
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion zingo-sync/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,34 @@ where
let sync_state = wallet.get_sync_state().unwrap();
let fully_scanned_height = sync_state.fully_scanned_height();
let highest_scanned_height = sync_state.highest_scanned_height();
let sync_start_height = sync_state.initial_sync_state().sync_start_height();

let scanned_block_range_boundaries = sync_state
.scan_ranges()
.iter()
.filter(|scan_range| {
scan_range.priority() == ScanPriority::Scanned
&& scan_range.block_range().start >= sync_start_height
})
.flat_map(|scan_range| {
vec![
scan_range.block_range().start,
scan_range.block_range().end - 1,
]
})
.collect::<Vec<_>>();

let wallet_transaction_heights = wallet
.get_wallet_transactions()
.unwrap()
.values()
.filter_map(|tx| tx.confirmation_status().get_confirmed_height())
.collect::<Vec<_>>();

wallet.get_wallet_blocks_mut().unwrap().retain(|height, _| {
*height >= fully_scanned_height - 1
*height >= sync_start_height - 1
|| *height >= highest_scanned_height - MAX_VERIFICATION_WINDOW
|| scanned_block_range_boundaries.contains(height)
|| wallet_transaction_heights.contains(height)
});
wallet
Expand Down

0 comments on commit 23f4442

Please sign in to comment.