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§
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.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>,
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
.