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 should be the storage root of the used trie.

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.

Implementations on Foreign Types§

source§

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

§

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

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> where H: 'a = TrieCache<'a, H>

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§