Trait sp_state_machine::TrieCacheProvider
source · pub trait TrieCacheProvider<H: Hasher> {
type Cache<'a>: TrieCacheT<NodeCodec<H>> + 'a
where Self: 'a;
// Required methods
fn as_trie_db_cache(&self, storage_root: H::Out) -> Self::Cache<'_>;
fn as_trie_db_mut_cache(&self) -> Self::Cache<'_>;
fn merge<'a>(&'a self, other: Self::Cache<'a>, new_root: H::Out);
}
Expand description
A provider of trie caches that are compatible with [trie_db::TrieDB
].
Required Associated Types§
Required Methods§
sourcefn as_trie_db_cache(&self, storage_root: H::Out) -> Self::Cache<'_>
fn as_trie_db_cache(&self, storage_root: H::Out) -> Self::Cache<'_>
Return a [trie_db::TrieDB
] compatible cache.
The storage_root
parameter should be the storage root of the used trie.
sourcefn as_trie_db_mut_cache(&self) -> Self::Cache<'_>
fn as_trie_db_mut_cache(&self) -> Self::Cache<'_>
Returns a cache that can be used with a [trie_db::TrieDBMut
].
When finished with the operation on the trie, it is required to call Self::merge
to
merge the cached items for the correct storage_root
.
sourcefn merge<'a>(&'a self, other: Self::Cache<'a>, new_root: H::Out)
fn merge<'a>(&'a self, other: Self::Cache<'a>, new_root: H::Out)
Merge the cached data in other
into the provider using the given new_root
.
This must be used for the cache returned by Self::as_trie_db_mut_cache
as otherwise the
cached data is just thrown away.