async fn run_cold(engine: &dyn EngineOperations) -> Result<(Arc<BlockHandle>, Option<ShardStateStuff>, Option<BlockProofStuff>)> {
    let block_id = engine.init_mc_block_id();
    log::info!(target: "boot", "cold boot start: init_block_id={}", block_id);
    CHECK!(block_id.shard().is_masterchain());
    CHECK!(block_id.seq_no >= engine.get_last_fork_masterchain_seqno());
    let handle = engine.load_block_handle(&block_id)?;
    if block_id.seq_no() == 0 {
        log::info!(target: "boot", "download zero state {}", block_id);
        let zero_state = download_zero_state(engine, &handle).await?;
        Ok((handle, Some(zero_state), None))
    } else {
        // id should be key block if not it will never sync
        log::info!(target: "boot", "download init block proof link {}", block_id);
        let proof = if handle.proof_link_inited() || handle.proof_inited() {
            match engine.load_block_proof(&handle, true).await {
                Ok(proof) => proof,
                Err(err) => {
                    log::warn!(target: "boot", "load_block_proof for init_block {} error: {}", handle.id(), err);
                    engine.load_block_proof(&handle, false).await?
                }
            }
        } else {
            loop {
                match engine.download_block_proof(&block_id, true, true).await {
                    Ok(proof) => match proof.check_proof_link() {
                        Ok(_) => {
                            engine.store_block_proof(&handle, &proof).await?;
                            break proof
                        }
                        Err(err) => log::warn!(target: "boot", "check_proof_link for init_block {} error: {}", handle.id(), err)
                    }
                    Err(err) => log::warn!(target: "boot", "download block proof link for init_block {} error: {}", handle.id(), err)
                }
                futures_timer::Delay::new(Duration::from_secs(1)).await;
            }
        };
        CHECK!(handle.is_key_block()?);
        Ok((handle, None, Some(proof)))
    }
}
/// cold boot entry point
/// download zero state or block proof link and check it
cold boot entry point
download zero state or block proof link and check it
cold boot entry point download zero state or block proof link and check it
async fn run_cold(engine: &dyn EngineOperations) -> Result<(Arc<BlockHandle>, Option<ShardStateStuff>, Option<BlockProofStuff>)> {
    let block_id = engine.init_mc_block_id();
    log::info!(target: "boot", "cold boot start: init_block_id={}", block_id);
    CHECK!(block_id.shard().is_masterchain());
    CHECK!(block_id.seq_no >= engine.get_last_fork_masterchain_seqno());
    let handle = engine.load_block_handle(&block_id)?;
    if block_id.seq_no() == 0 {
        log::info!(target: "boot", "download zero state {}", block_id);
        let zero_state = download_zero_state(engine, &handle).await?;
        Ok((handle, Some(zero_state), None))
    } else {
        // id should be key block if not it will never sync
        log::info!(target: "boot", "download init block proof link {}", block_id);
        let proof = if handle.proof_link_inited() || handle.proof_inited() {
            match engine.load_block_proof(&handle, true).await {
                Ok(proof) => proof,
                Err(err) => {
                    log::warn!(target: "boot", "load_block_proof for init_block {} error: {}", handle.id(), err);
                    engine.load_block_proof(&handle, false).await?
                }
            }
        } else {
            loop {
                match engine.download_block_proof(&block_id, true, true).await {
                    Ok(proof) => match proof.check_proof_link() {
                        Ok(_) => {
                            engine.store_block_proof(&handle, &proof).await?;
                            break proof
                        }
                        Err(err) => log::warn!(target: "boot", "check_proof_link for init_block {} error: {}", handle.id(), err)
                    }
                    Err(err) => log::warn!(target: "boot", "download block proof link for init_block {} error: {}", handle.id(), err)
                }
                futures_timer::Delay::new(Duration::from_secs(1)).await;
            }
        };
        CHECK!(handle.is_key_block()?);
        Ok((handle, None, Some(proof)))
    }
}
async fn run_cold ( engine : & dyn EngineOperations ) -> Result < ( Arc < BlockHandle > , Option < ShardStateStuff > , Option < BlockProofStuff > ) > { let block_id = engine . init_mc_block_id ( ) ; log :: info ! ( target " " " " block_id ) ; CHECK ! ( block_id shard ( ) is_masterchain ( ) ) ; CHECK ! ( block_id seq_no engine get_last_fork_masterchain_seqno ( ) ) ; let handle = engine . load_block_handle ( & block_id ) ? ; if block_id . seq_no ( ) == 0 { log :: info ! ( target " " " " block_id ) ; let zero_state = download_zero_state ( engine , & handle ) . await ? ; Ok ( ( handle , Some ( zero_state ) , None ) ) } else { // id should be key block if not it will never sync log :: info ! ( target " " " " block_id ) ; let proof = if handle . proof_link_inited ( ) || handle . proof_inited ( ) { match engine . load_block_proof ( & handle , true ) . await { Ok ( proof ) => proof , Err ( err ) => { log :: warn ! ( target " " " " handle id ( ) err ) ; engine . load_block_proof ( & handle , false ) . await ? } } } else { loop { match engine . download_block_proof ( & block_id , true , true ) . await { Ok ( proof ) => match proof . check_proof_link ( ) { Ok ( _ ) => { engine . store_block_proof ( & handle , & proof ) . await ? ; break proof } Err ( err ) => log :: warn ! ( target " " " " handle id ( ) err ) } Err ( err ) => log :: warn ! ( target " " " " handle id ( ) err ) } futures_timer :: Delay :: new ( Duration :: from_secs ( 1 ) ) . await ; } } ; CHECK ! ( handle is_key_block ( ) ) ; Ok ( ( handle , None , Some ( proof ) ) ) } }
cold boot entry point
download zero state or block proof link and check it
cold boot entry point download zero state or block proof link and check it
engine
&dyn EngineOperations
engine
&dyn EngineOperations