Struct sp_trie::recorder::Recorder

source ·
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>

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn reset(&self)

Reset the state.

This discards all recorded data.

source

pub fn start_transaction(&self)

Start a new transaction.

source

pub fn rollback_transaction(&self) -> Result<(), ()>

Rollback the latest transaction.

Returns an error if there wasn’t any active transaction.

source

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> Clone for Recorder<H>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<H: Hasher> Default for Recorder<H>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<H: Hasher> ProofSizeProvider for Recorder<H>

source§

fn estimate_encoded_size(&self) -> usize

Returns the storage proof size.
source§

impl<H: Hasher> TrieRecorderProvider<H> for Recorder<H>

§

type Recorder<'a> = TrieRecorder<'a, H> where H: 'a

Recorder type that is going to be returned by implementors of this trait.
source§

fn drain_storage_proof(self) -> Option<StorageProof>

Create a StorageProof derived from the internal state.
source§

fn as_trie_recorder(&self, storage_root: H::Out) -> Self::Recorder<'_>

Provide a recorder implementing 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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
source§

impl<T, Outer> IsWrappedBy<Outer> for T
where Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,

source§

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

source§

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<S, T> UncheckedInto<T> for S
where T: UncheckedFrom<S>,

source§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> JsonSchemaMaybe for T