sp_state_machine

Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

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

Source§

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>

Source§

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§