pub trait StateProvider {
type Error;
type Reader: StateReader<Key, StoredValue, Error = Self::Error>;
fn checkout(
&self,
state_hash: Digest
) -> Result<Option<Self::Reader>, Self::Error>;
fn commit(
&self,
correlation_id: CorrelationId,
state_hash: Digest,
effects: AdditiveMap<Key, Transform>
) -> Result<Digest, Self::Error>;
fn empty_root(&self) -> Digest;
fn get_trie(
&self,
correlation_id: CorrelationId,
trie_key: &Digest
) -> Result<Option<Trie<Key, StoredValue>>, Self::Error>;
fn put_trie(
&self,
correlation_id: CorrelationId,
trie: &Trie<Key, StoredValue>
) -> Result<Digest, Self::Error>;
fn missing_trie_keys(
&self,
correlation_id: CorrelationId,
trie_keys: Vec<Digest>
) -> Result<Vec<Digest>, Self::Error>;
}
Expand description
A trait expressing operations over the trie.
Associated Types
type Reader: StateReader<Key, StoredValue, Error = Self::Error>
type Reader: StateReader<Key, StoredValue, Error = Self::Error>
Associated reader type for StateProvider
.
Required methods
Checkouts to the post state of a specific block.
fn commit(
&self,
correlation_id: CorrelationId,
state_hash: Digest,
effects: AdditiveMap<Key, Transform>
) -> Result<Digest, Self::Error>
fn commit(
&self,
correlation_id: CorrelationId,
state_hash: Digest,
effects: AdditiveMap<Key, Transform>
) -> Result<Digest, Self::Error>
Applies changes and returns a new post state hash. block_hash is used for computing a deterministic and unique keys.
fn empty_root(&self) -> Digest
fn empty_root(&self) -> Digest
Returns an empty root hash.
fn get_trie(
&self,
correlation_id: CorrelationId,
trie_key: &Digest
) -> Result<Option<Trie<Key, StoredValue>>, Self::Error>
fn get_trie(
&self,
correlation_id: CorrelationId,
trie_key: &Digest
) -> Result<Option<Trie<Key, StoredValue>>, Self::Error>
Reads a Trie
from the state if it is present
fn put_trie(
&self,
correlation_id: CorrelationId,
trie: &Trie<Key, StoredValue>
) -> Result<Digest, Self::Error>
fn put_trie(
&self,
correlation_id: CorrelationId,
trie: &Trie<Key, StoredValue>
) -> Result<Digest, Self::Error>
Insert a trie node into the trie
fn missing_trie_keys(
&self,
correlation_id: CorrelationId,
trie_keys: Vec<Digest>
) -> Result<Vec<Digest>, Self::Error>
fn missing_trie_keys(
&self,
correlation_id: CorrelationId,
trie_keys: Vec<Digest>
) -> Result<Vec<Digest>, Self::Error>
Finds all of the missing or corrupt keys of which are descendants of trie_key