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 fulfilled 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> !Freeze for LocalTrieCache<H>
impl<H> !RefUnwindSafe for LocalTrieCache<H>
impl<H> Send for LocalTrieCache<H>
impl<H> Sync for LocalTrieCache<H>
impl<H> Unpin for LocalTrieCache<H>
impl<H> !UnwindSafe for LocalTrieCache<H>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> 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
.