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§
sourcetype Reader: StateReader<Key, StoredValue, Error = Self::Error>
type Reader: StateReader<Key, StoredValue, Error = Self::Error>
Associated reader type for StateProvider
.
Required Methods§
sourcefn checkout(
&self,
state_hash: Digest
) -> Result<Option<Self::Reader>, Self::Error>
fn checkout( &self, state_hash: Digest ) -> Result<Option<Self::Reader>, Self::Error>
Checkouts to the post state of a specific block.
sourcefn empty_root(&self) -> Digest
fn empty_root(&self) -> Digest
Returns an empty root hash.
sourcefn get_trie_full(
&self,
correlation_id: CorrelationId,
trie_key: &Digest
) -> Result<Option<TrieRaw>, Self::Error>
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
sourcefn put_trie(
&self,
correlation_id: CorrelationId,
trie: &[u8]
) -> Result<Digest, Self::Error>
fn put_trie( &self, correlation_id: CorrelationId, trie: &[u8] ) -> Result<Digest, Self::Error>
Insert a trie node into the trie
sourcefn missing_children(
&self,
correlation_id: CorrelationId,
trie_raw: &[u8]
) -> Result<Vec<Digest>, Self::Error>
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.
sourcefn delete_keys(
&self,
correlation_id: CorrelationId,
root: Digest,
keys_to_delete: &[Key]
) -> Result<DeleteResult, Self::Error>
fn delete_keys( &self, correlation_id: CorrelationId, root: Digest, keys_to_delete: &[Key] ) -> Result<DeleteResult, Self::Error>
Delete key from the global state.