Struct sp_trie::cache::LocalTrieCache
source · pub struct LocalTrieCache<H: Hasher> { /* private fields */ }
Expand description
The local trie cache.
This cache should be used per state instance created by the backend. One state instance is
referring to the state of one block. It will cache all the accesses that are done to the state
which could not be fullfilled by the SharedTrieCache
. These locally cached items are merged
back to the shared trie cache when this instance is dropped.
When using Self::as_trie_db_cache
or Self::as_trie_db_mut_cache
, it will lock Mutexes.
So, it is important that these methods are not called multiple times, because they otherwise
deadlock.
Implementations§
source§impl<H: Hasher> LocalTrieCache<H>
impl<H: Hasher> LocalTrieCache<H>
sourcepub fn as_trie_db_cache(&self, storage_root: H::Out) -> TrieCache<'_, H>
pub fn as_trie_db_cache(&self, storage_root: H::Out) -> TrieCache<'_, H>
Return self as a TrieDB
compatible cache.
The given storage_root
needs to be the storage root of the trie this cache is used for.
sourcepub fn as_trie_db_mut_cache(&self) -> TrieCache<'_, H>
pub fn as_trie_db_mut_cache(&self) -> TrieCache<'_, H>
Return self as TrieDBMut
compatible cache.
After finishing all operations with TrieDBMut
and having obtained
the new storage root, TrieCache::merge_into
should be called to update this local
cache instance. If the function is not called, cached data is just thrown away and not
propagated to the shared cache. So, accessing these new items will be slower, but nothing
would break because of this.
Trait Implementations§
Auto Trait Implementations§
impl<H> !RefUnwindSafe for LocalTrieCache<H>
impl<H> Send for LocalTrieCache<H>
impl<H> Sync for LocalTrieCache<H>
impl<H> Unpin for LocalTrieCache<H>where <H as Hasher>::Out: Unpin,
impl<H> !UnwindSafe for LocalTrieCache<H>
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.