pub async fn process_missed_blocks<S, C, H, T, TR>(
network: &Network,
recovery_config: &BlockRecoveryConfig,
rpc_client: &C,
block_storage: Arc<S>,
block_handler: Arc<H>,
trigger_handler: Arc<T>,
_block_tracker: Arc<TR>,
) -> Result<RecoveryResult, BlockWatcherError>where
S: BlockStorage + Send + Sync,
C: BlockChainClient + Send + Sync,
H: Fn(BlockType, Network) -> BoxFuture<'static, ProcessedBlock> + Send + Sync,
T: Fn(&ProcessedBlock) -> JoinHandle<()> + Send + Sync,
TR: BlockTrackerTrait + Send + Sync,Expand description
Processes missed blocks for recovery
This function runs as part of the recovery job and attempts to fetch and process blocks that were previously missed.
ยงAlgorithm
- Get current block number
- Prune blocks older than
max_block_age - Load missed blocks with
status == Pendingandretry_count < max_retries - Limit to
max_blocks_per_run, sorted by block number (oldest first) - For each block:
- Mark as
Recovering - Fetch via RPC
- On success: process through handlers, mark
Recovered, remove from file - On failure: increment
retry_count, record error, applyretry_delay_ms - If
retry_count >= max_retries: mark asFailed
- Mark as
- Return statistics