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§

source

type Cache<'a>: TrieCacheT<NodeCodec<H>> + 'a where Self: 'a

Cache type that implements [trie_db::TrieCache].

Required Methods§

source

fn as_trie_db_cache(&self, storage_root: H::Out) -> Self::Cache<'_>

Return a [trie_db::TrieDB] compatible cache.

The storage_root parameter must be the storage root of the trie this cache is used for.

NOTE: Implementors should use the storage_root to differentiate between storage keys that may belong to different tries.

source

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.

source

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<H: Hasher> TrieCacheProvider<H> for &LocalTrieCache<H>

§

type Cache<'a> = TrieCache<'a, H> where Self: 'a

source§

fn as_trie_db_cache(&self, storage_root: H::Out) -> Self::Cache<'_>

source§

fn as_trie_db_mut_cache(&self) -> Self::Cache<'_>

source§

fn merge<'a>(&'a self, other: Self::Cache<'a>, new_root: H::Out)

source§

impl<H: Hasher> TrieCacheProvider<H> for LocalTrieCache<H>

§

type Cache<'a> = TrieCache<'a, H> where H: 'a

source§

fn as_trie_db_cache(&self, storage_root: H::Out) -> Self::Cache<'_>

source§

fn as_trie_db_mut_cache(&self) -> Self::Cache<'_>

source§

fn merge<'a>(&'a self, other: Self::Cache<'a>, new_root: H::Out)

Implementors§