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§

source

fn get(&self, access_key: StorageKeyWithSpace<'_>) -> Result<Option<Box<[u8]>>>

source

fn set( &mut self, access_key: StorageKeyWithSpace<'_>, value: Box<[u8]> ) -> Result<()>

source

fn delete(&mut self, access_key: StorageKeyWithSpace<'_>) -> Result<()>

source

fn delete_test_only( &mut self, access_key: StorageKeyWithSpace<'_> ) -> Result<Option<Box<[u8]>>>

source

fn delete_all( &mut self, access_key_prefix: StorageKeyWithSpace<'_> ) -> Result<Option<Vec<MptKeyValue>>>

source

fn read_all( &mut self, access_key_prefix: StorageKeyWithSpace<'_> ) -> Result<Option<Vec<MptKeyValue>>>

source

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.

source

fn get_state_root(&self) -> Result<StateRootWithAuxInfo>

source

fn commit(&mut self, epoch: EpochId) -> Result<StateRootWithAuxInfo>

Implementors§