pub type ProofRecorder<B> = Recorder<HashingFor<B>>;
Expand description
A type that records all accessed trie nodes and generates a proof out of it.
Aliased Type§
struct ProofRecorder<B> { /* private fields */ }
Implementations
§impl<H> Recorder<H>where
H: Hasher,
impl<H> Recorder<H>where
H: Hasher,
pub 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.
pub fn as_trie_recorder(
&self,
storage_root: <H as Hasher>::Out,
) -> TrieRecorder<'_, H>
pub fn as_trie_recorder( &self, storage_root: <H as Hasher>::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.
pub 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
.
pub 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
.
pub 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.
pub fn reset(&self)
pub fn reset(&self)
Reset the state.
This discards all recorded data.
pub fn start_transaction(&self)
pub fn start_transaction(&self)
Start a new transaction.
pub 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.
pub 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
§impl<H> ProofSizeProvider for Recorder<H>where
H: Hasher,
impl<H> ProofSizeProvider for Recorder<H>where
H: Hasher,
§fn estimate_encoded_size(&self) -> usize
fn estimate_encoded_size(&self) -> usize
§impl<H> TrieRecorderProvider<H> for Recorder<H>where
H: Hasher,
impl<H> TrieRecorderProvider<H> for Recorder<H>where
H: Hasher,
§type Recorder<'a> = TrieRecorder<'a, H>
where
H: 'a
type Recorder<'a> = TrieRecorder<'a, H> where H: 'a
§fn drain_storage_proof(self) -> Option<StorageProof>
fn drain_storage_proof(self) -> Option<StorageProof>
StorageProof
derived from the internal state.§fn as_trie_recorder(
&self,
storage_root: <H as Hasher>::Out,
) -> <Recorder<H> as TrieRecorderProvider<H>>::Recorder<'_>
fn as_trie_recorder( &self, storage_root: <H as Hasher>::Out, ) -> <Recorder<H> as TrieRecorderProvider<H>>::Recorder<'_>
trie_db::TrieRecorder
].