Function process_missed_blocks

Source
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

  1. Get current block number
  2. Prune blocks older than max_block_age
  3. Load missed blocks with status == Pending and retry_count < max_retries
  4. Limit to max_blocks_per_run, sorted by block number (oldest first)
  5. 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, apply retry_delay_ms
    • If retry_count >= max_retries: mark as Failed
  6. Return statistics