pub struct Recorder<H: Hasher> { /* private fields */ }
Expand description
The trie recorder.
Owns the recorded data. Is used to transform data into a storage
proof and to provide transaction support. The as_trie_recorder
method provides a
trie_db::TrieDB
compatible recorder that implements the actual recording logic.
Implementations§
source§impl<H: Hasher> Recorder<H>
impl<H: Hasher> Recorder<H>
sourcepub fn recorded_keys(
&self,
) -> HashMap<<H as Hasher>::Out, HashMap<Arc<[u8]>, RecordedForKey>>
pub fn recorded_keys( &self, ) -> HashMap<<H as Hasher>::Out, HashMap<Arc<[u8]>, RecordedForKey>>
Returns RecordedForKey
per recorded key per trie.
There are multiple tries when working with e.g. child tries.
sourcepub fn as_trie_recorder(&self, storage_root: H::Out) -> TrieRecorder<'_, H>
pub fn as_trie_recorder(&self, storage_root: H::Out) -> TrieRecorder<'_, H>
Returns the recorder as TrieRecorder
compatible type.
storage_root
: The storage root of the trie for which accesses are recorded. This is important when recording access to different tries at once (like top and child tries).
NOTE: This locks a mutex that stays locked until the return value is dropped.
sourcepub fn drain_storage_proof(self) -> StorageProof
pub fn drain_storage_proof(self) -> StorageProof
Drain the recording into a StorageProof
.
While a recorder can be cloned, all share the same internal state. After calling this function, all other instances will have their internal state reset as well.
If you don’t want to drain the recorded state, use Self::to_storage_proof
.
Returns the StorageProof
.
sourcepub fn to_storage_proof(&self) -> StorageProof
pub fn to_storage_proof(&self) -> StorageProof
Convert the recording to a StorageProof
.
In contrast to Self::drain_storage_proof
this doesn’t consume and doesn’t clear the
recordings.
Returns the StorageProof
.
sourcepub fn estimate_encoded_size(&self) -> usize
pub fn estimate_encoded_size(&self) -> usize
Returns the estimated encoded size of the proof.
The estimation is based on all the nodes that were accessed until now while accessing the trie.
sourcepub fn start_transaction(&self)
pub fn start_transaction(&self)
Start a new transaction.
sourcepub fn rollback_transaction(&self) -> Result<(), ()>
pub fn rollback_transaction(&self) -> Result<(), ()>
Rollback the latest transaction.
Returns an error if there wasn’t any active transaction.
sourcepub fn commit_transaction(&self) -> Result<(), ()>
pub fn commit_transaction(&self) -> Result<(), ()>
Commit the latest transaction.
Returns an error if there wasn’t any active transaction.
Trait Implementations§
source§impl<H: Hasher> ProofSizeProvider for Recorder<H>
impl<H: Hasher> ProofSizeProvider for Recorder<H>
source§fn estimate_encoded_size(&self) -> usize
fn estimate_encoded_size(&self) -> usize
source§impl<H: Hasher> TrieRecorderProvider<H> for Recorder<H>
impl<H: Hasher> TrieRecorderProvider<H> for Recorder<H>
§type Recorder<'a> = TrieRecorder<'a, H>
where
H: 'a
type Recorder<'a> = TrieRecorder<'a, H> where H: 'a
source§fn drain_storage_proof(self) -> Option<StorageProof>
fn drain_storage_proof(self) -> Option<StorageProof>
StorageProof
derived from the internal state.source§fn as_trie_recorder(&self, storage_root: H::Out) -> Self::Recorder<'_>
fn as_trie_recorder(&self, storage_root: H::Out) -> Self::Recorder<'_>
trie_db::TrieRecorder
.Auto Trait Implementations§
impl<H> Freeze for Recorder<H>
impl<H> !RefUnwindSafe for Recorder<H>
impl<H> Send for Recorder<H>
impl<H> Sync for Recorder<H>
impl<H> Unpin for Recorder<H>
impl<H> !UnwindSafe for Recorder<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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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
.