pub trait StateProvider {
    type Error;
    type Reader: StateReader<Key, StoredValue, Error = Self::Error>;

    // Required methods
    fn checkout(
        &self,
        state_hash: Digest
    ) -> Result<Option<Self::Reader>, Self::Error>;
    fn empty_root(&self) -> Digest;
    fn get_trie_full(
        &self,
        correlation_id: CorrelationId,
        trie_key: &Digest
    ) -> Result<Option<TrieRaw>, Self::Error>;
    fn put_trie(
        &self,
        correlation_id: CorrelationId,
        trie: &[u8]
    ) -> Result<Digest, Self::Error>;
    fn missing_children(
        &self,
        correlation_id: CorrelationId,
        trie_raw: &[u8]
    ) -> Result<Vec<Digest>, Self::Error>;
    fn delete_keys(
        &self,
        correlation_id: CorrelationId,
        root: Digest,
        keys_to_delete: &[Key]
    ) -> Result<DeleteResult, Self::Error>;
}
Expand description

A trait expressing operations over the trie.

Required Associated Types§

source

type Error

Associated error type for StateProvider.

source

type Reader: StateReader<Key, StoredValue, Error = Self::Error>

Associated reader type for StateProvider.

Required Methods§

source

fn checkout( &self, state_hash: Digest ) -> Result<Option<Self::Reader>, Self::Error>

Checkouts to the post state of a specific block.

source

fn empty_root(&self) -> Digest

Returns an empty root hash.

source

fn get_trie_full( &self, correlation_id: CorrelationId, trie_key: &Digest ) -> Result<Option<TrieRaw>, Self::Error>

Reads a full Trie (never chunked) from the state if it is present

source

fn put_trie( &self, correlation_id: CorrelationId, trie: &[u8] ) -> Result<Digest, Self::Error>

Insert a trie node into the trie

source

fn missing_children( &self, correlation_id: CorrelationId, trie_raw: &[u8] ) -> Result<Vec<Digest>, Self::Error>

Finds all the children of trie_raw which aren’t present in the state.

source

fn delete_keys( &self, correlation_id: CorrelationId, root: Digest, keys_to_delete: &[Key] ) -> Result<DeleteResult, Self::Error>

Delete key from the global state.

Implementors§