Struct sp_trie::recorder::Recorder

source ·
pub struct Recorder<H: Hasher> { /* private fields */ }
Expand description

The trie recorder.

It can be used to record accesses to the trie and then to convert them into a StorageProof.

Implementations§

source§

impl<H: Hasher> Recorder<H>

source

pub fn as_trie_recorder( &self, storage_root: H::Out ) -> impl TrieRecorder<H::Out> + '_

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 consumes and doesn’t clears 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

Auto Trait Implementations§

§

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> 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, 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.
§

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

§

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