-
Notifications
You must be signed in to change notification settings - Fork 40
Open
0 / 10 of 1 issue completedOpen
0 / 10 of 1 issue completed
Copy link
Labels
Description
This reorg detection is only expected to run at initialization time. All other things being equal it would be nice to break it out cleanly into an obvious initialization scope.
zingolib/pepper-sync/src/sync.rs
Lines 1452 to 1493 in 9b2bb0f
| { | |
| tracing::info!("Re-org detected."); | |
| let sync_state = wallet | |
| .get_sync_state_mut() | |
| .map_err(SyncError::WalletError)?; | |
| let last_known_chain_height = sync_state | |
| .last_known_chain_height() | |
| .expect("scan ranges should be non-empty in this scope"); | |
| // reset scan range from `Scanning` to `Verify` | |
| state::set_scan_priority( | |
| sync_state, | |
| scan_range.block_range(), | |
| ScanPriority::Verify, | |
| ); | |
| // extend verification range to VERIFY_BLOCK_RANGE_SIZE blocks below current verification range | |
| let verification_start = state::set_verify_scan_range( | |
| sync_state, | |
| height - 1, | |
| state::VerifyEnd::VerifyHighest, | |
| ) | |
| .block_range() | |
| .start; | |
| state::merge_scan_ranges(sync_state, ScanPriority::Verify); | |
| if initial_unscanned_height - verification_start > MAX_REORG_ALLOWANCE { | |
| clear_wallet_data(wallet)?; | |
| return Err(ServerError::ChainVerificationError.into()); | |
| } | |
| truncate_wallet_data(wallet, verification_start - 1)?; | |
| state::set_initial_state( | |
| consensus_parameters, | |
| fetch_request_sender.clone(), | |
| wallet, | |
| last_known_chain_height, | |
| ) | |
| .await?; | |
| } else { |
Reactions are currently unavailable