/// Interate through commited blocks and build the block's state if it is missing
Interate through commited blocks and build the block's state if it is missing
Interate through commited blocks and build the block ' s state if it is missing
fn process_blocks(
    initial_state_root: &str,
    blocks: CommitStoreByHeightIterator,
    execution_task_submitter: &ExecutionTaskSubmitter,
    merkle_state: &CborMerkleState,
    state_view_factory: &StateViewFactory,
    scheduler_factory: &dyn SchedulerFactory,
) -> Result<(), StateVerificationError> {
    let mut previous_state_root = initial_state_root.to_string();
    for block in blocks {
        info!("Verifying state for block {}", block.header().block_num());
        match state_view_factory.create_view::<SettingsView>(block.header().state_root_hash()) {
            Ok(_) => (),
            Err(_) => {
                // If creating the view fails, the root is missing so we should
                // recompute it and verify it
                execute_batches(
                    &previous_state_root,
                    execution_task_submitter,
                    merkle_state,
                    block.block().batches().to_vec(),
                    &*scheduler_factory,
                    hex::encode(block.header().state_root_hash()),
                )?
            }
        }
        previous_state_root = hex::encode(block.header().state_root_hash());
    }
    Ok(())
}
fn process_blocks ( initial_state_root : & str , blocks : CommitStoreByHeightIterator , execution_task_submitter : & ExecutionTaskSubmitter , merkle_state : & CborMerkleState , state_view_factory : & StateViewFactory , scheduler_factory : & dyn SchedulerFactory , ) -> Result < ( ) , StateVerificationError > { let mut previous_state_root = initial_state_root . to_string ( ) ; for block in blocks { info ! ( " " block header ( ) block_num ( ) ) ; match state_view_factory . create_view :: < SettingsView > ( block . header ( ) . state_root_hash ( ) ) { Ok ( _ ) => ( ) , Err ( _ ) => { // If creating the view fails, the root is missing so we should // recompute it and verify it execute_batches ( & previous_state_root , execution_task_submitter , merkle_state , block . block ( ) . batches ( ) . to_vec ( ) , & * scheduler_factory , hex :: encode ( block . header ( ) . state_root_hash ( ) ) , ) ? } } previous_state_root = hex :: encode ( block . header ( ) . state_root_hash ( ) ) ; } Ok ( ( ) ) }
Interate through commited blocks and build the block's state if it is missing
Interate through commited blocks and build the block ' s state if it is missing
initial_state_root
&str
blocks
CommitStoreByHeightIterator
execution_task_submitter
&ExecutionTaskSubmitter
merkle_state
&CborMerkleState
state_view_factory
&StateViewFactory
scheduler_factory
&dyn SchedulerFactory