Trait cfx_storage::state::StateTrait
source · pub trait StateTrait: Sync + Send {
// Required methods
fn get(
&self,
access_key: StorageKeyWithSpace<'_>
) -> Result<Option<Box<[u8]>>>;
fn set(
&mut self,
access_key: StorageKeyWithSpace<'_>,
value: Box<[u8]>
) -> Result<()>;
fn delete(&mut self, access_key: StorageKeyWithSpace<'_>) -> Result<()>;
fn delete_test_only(
&mut self,
access_key: StorageKeyWithSpace<'_>
) -> Result<Option<Box<[u8]>>>;
fn delete_all(
&mut self,
access_key_prefix: StorageKeyWithSpace<'_>
) -> Result<Option<Vec<MptKeyValue>>>;
fn read_all(
&mut self,
access_key_prefix: StorageKeyWithSpace<'_>
) -> Result<Option<Vec<MptKeyValue>>>;
fn compute_state_root(&mut self) -> Result<StateRootWithAuxInfo>;
fn get_state_root(&self) -> Result<StateRootWithAuxInfo>;
fn commit(&mut self, epoch: EpochId) -> Result<StateRootWithAuxInfo>;
}
Required Methods§
fn get(&self, access_key: StorageKeyWithSpace<'_>) -> Result<Option<Box<[u8]>>>
fn set( &mut self, access_key: StorageKeyWithSpace<'_>, value: Box<[u8]> ) -> Result<()>
fn delete(&mut self, access_key: StorageKeyWithSpace<'_>) -> Result<()>
fn delete_test_only( &mut self, access_key: StorageKeyWithSpace<'_> ) -> Result<Option<Box<[u8]>>>
fn delete_all( &mut self, access_key_prefix: StorageKeyWithSpace<'_> ) -> Result<Option<Vec<MptKeyValue>>>
fn read_all( &mut self, access_key_prefix: StorageKeyWithSpace<'_> ) -> Result<Option<Vec<MptKeyValue>>>
sourcefn compute_state_root(&mut self) -> Result<StateRootWithAuxInfo>
fn compute_state_root(&mut self) -> Result<StateRootWithAuxInfo>
It’s costly to compute state root however it’s only necessary to compute state root once before committing.