pub fn detach_block_state(&mut self) -> Result<()> {
        let block_number = match self.context {
            StateContext::DetachBlock(block_number) => block_number,
            ctx => return Err(anyhow!("Wrong context in detach block state: {:?}", ctx)),
        };

        // reset states to previous value
        let parent_block_number = block_number.saturating_sub(1);
        let reverted_key_values: Vec<_> = self
            .db()
            .iter_block_state_record(block_number)
            .map(|record_key| {
                let state_key = record_key.state_key();
                let last_value = self
                    .db()
                    .get_history_state(parent_block_number, &state_key)
                    .unwrap_or_else(H256::zero);
                (state_key, last_value)
            })
            .collect();
        for (state_key, last_value) in reverted_key_values {
            self.update_raw(state_key, last_value)?;
        }

        // remove block's state record
        self.db().remove_block_state_record(block_number)?;

        Ok(())
    }
/// Detach block state from state tree
Detach block state from state tree
Detach block state from state tree
pub fn detach_block_state(&mut self) -> Result<()> {
        let block_number = match self.context {
            StateContext::DetachBlock(block_number) => block_number,
            ctx => return Err(anyhow!("Wrong context in detach block state: {:?}", ctx)),
        };
        // reset states to previous value
        let parent_block_number = block_number.saturating_sub(1);
        let reverted_key_values: Vec<_> = self
            .db()
            .iter_block_state_record(block_number)
            .map(|record_key| {
                let state_key = record_key.state_key();
                let last_value = self
                    .db()
                    .get_history_state(parent_block_number, &state_key)
                    .unwrap_or_else(H256::zero);
                (state_key, last_value)
            })
            .collect();
        for (state_key, last_value) in reverted_key_values {
            self.update_raw(state_key, last_value)?;
        }
        // remove block's state record
        self.db().remove_block_state_record(block_number)?;
        Ok(())
    }
pub fn detach_block_state ( & mut self ) -> Result < ( ) > { let block_number = match self . context { StateContext :: DetachBlock ( block_number ) => block_number , ctx => return Err ( anyhow ! ( " " ctx ) ) , } ; // reset states to previous value let parent_block_number = block_number . saturating_sub ( 1 ) ; let reverted_key_values : Vec < _ > = self . db ( ) . iter_block_state_record ( block_number ) . map ( | record_key | { let state_key = record_key . state_key ( ) ; let last_value = self . db ( ) . get_history_state ( parent_block_number , & state_key ) . unwrap_or_else ( H256 :: zero ) ; ( state_key , last_value ) } ) . collect ( ) ; for ( state_key , last_value ) in reverted_key_values { self . update_raw ( state_key , last_value ) ? ; } // remove block's state record self . db ( ) . remove_block_state_record ( block_number ) ? ; Ok ( ( ) ) }
Detach block state from state tree
Detach block state from state tree
&mut self
&mut self