pub fn execute_and_insert_block(&self, block: Block) -> anyhow::Result<Arc<ExecutedBlock>> {
        if let Some(existing_block) = self.get_block(block.id()) {
            return Ok(existing_block);
        }
        ensure!(
            self.inner.read().unwrap().root().round() < block.round(),
            "Block with old round"
        );

        let executed_block = match self.execute_block(block.clone()) {
            Ok(res) => Ok(res),
            Err(Error::BlockNotFound(parent_block_id)) => {
                // recover the block tree in executor
                let blocks_to_reexecute = self
                    .path_from_root(parent_block_id)
                    .unwrap_or_else(Vec::new);

                for block in blocks_to_reexecute {
                    self.execute_block(block.block().clone())?;
                }
                self.execute_block(block)
            }
            err => err,
        }?;

        // ensure local time past the block time
        let block_time = Duration::from_micros(executed_block.timestamp_usecs());
        self.time_service.wait_until(block_time);
        self.storage
            .save_tree(vec![executed_block.block().clone()], vec![])
            .context("Insert block failed when saving block")?;
        self.inner.write().unwrap().insert_block(executed_block)
    }
/// Execute and insert a block if it passes all validation tests.
/// Returns the Arc to the block kept in the block store after persisting it to storage
///
/// This function assumes that the ancestors are present (returns MissingParent otherwise).
///
/// Duplicate inserts will return the previously inserted block (
/// note that it is considered a valid non-error case, for example, it can happen if a validator
/// receives a certificate for a block that is currently being added).
Execute and insert a block if it passes all validation tests.
Returns the Arc to the block kept in the block store after persisting it to storage

This function assumes that the ancestors are present (returns MissingParent otherwise).

Duplicate inserts will return the previously inserted block (
note that it is considered a valid non-error case, for example, it can happen if a validator
receives a certificate for a block that is currently being added).
Execute and insert a block if it passes all validation tests . Returns the Arc to the block kept in the block store after persisting it to storage This function assumes that the ancestors are present ( returns MissingParent otherwise ) . Duplicate inserts will return the previously inserted block ( note that it is considered a valid non - error case for example it can happen if a validator receives a certificate for a block that is currently being added ) .
pub fn execute_and_insert_block(&self, block: Block) -> anyhow::Result<Arc<ExecutedBlock>> {
        if let Some(existing_block) = self.get_block(block.id()) {
            return Ok(existing_block);
        }
        ensure!(
            self.inner.read().unwrap().root().round() < block.round(),
            "Block with old round"
        );
        let executed_block = match self.execute_block(block.clone()) {
            Ok(res) => Ok(res),
            Err(Error::BlockNotFound(parent_block_id)) => {
                // recover the block tree in executor
                let blocks_to_reexecute = self
                    .path_from_root(parent_block_id)
                    .unwrap_or_else(Vec::new);
                for block in blocks_to_reexecute {
                    self.execute_block(block.block().clone())?;
                }
                self.execute_block(block)
            }
            err => err,
        }?;
        // ensure local time past the block time
        let block_time = Duration::from_micros(executed_block.timestamp_usecs());
        self.time_service.wait_until(block_time);
        self.storage
            .save_tree(vec![executed_block.block().clone()], vec![])
            .context("Insert block failed when saving block")?;
        self.inner.write().unwrap().insert_block(executed_block)
    }
pub fn execute_and_insert_block ( & self , block : Block ) -> anyhow :: Result < Arc < ExecutedBlock > > { if let Some ( existing_block ) = self . get_block ( block . id ( ) ) { return Ok ( existing_block ) ; } ensure ! ( self inner read ( ) unwrap ( ) root ( ) round ( ) block round ( ) " " ) ; let executed_block = match self . execute_block ( block . clone ( ) ) { Ok ( res ) => Ok ( res ) , Err ( Error :: BlockNotFound ( parent_block_id ) ) => { // recover the block tree in executor let blocks_to_reexecute = self . path_from_root ( parent_block_id ) . unwrap_or_else ( Vec :: new ) ; for block in blocks_to_reexecute { self . execute_block ( block . block ( ) . clone ( ) ) ? ; } self . execute_block ( block ) } err => err , } ? ; // ensure local time past the block time let block_time = Duration :: from_micros ( executed_block . timestamp_usecs ( ) ) ; self . time_service . wait_until ( block_time ) ; self . storage . save_tree ( vec ! [ executed_block block ( ) clone ( ) ] , vec ! [ ] ) . context ( " " ) ? ; self . inner . write ( ) . unwrap ( ) . insert_block ( executed_block ) }
Execute and insert a block if it passes all validation tests.
Execute and insert a block if it passes all validation tests .
&self
block
Block
&self
block
Block