Struct sp_trie::StorageProof
source · pub struct StorageProof { /* private fields */ }
Expand description
A proof that some set of key-value pairs are included in the storage trie. The proof contains the storage values so that the partial storage backend can be reconstructed by a verifier that does not already have access to the key-value pairs.
The proof consists of the set of serialized nodes in the storage trie accessed when looking up the keys covered by the proof. Verifying the proof requires constructing the partial trie from the serialized nodes and performing the key lookups.
Implementations§
source§impl StorageProof
impl StorageProof
sourcepub fn new(trie_nodes: impl IntoIterator<Item = Vec<u8>>) -> Self
pub fn new(trie_nodes: impl IntoIterator<Item = Vec<u8>>) -> Self
Constructs a storage proof from a subset of encoded trie nodes in a storage backend.
sourcepub fn new_with_duplicate_nodes_check(
trie_nodes: impl IntoIterator<Item = Vec<u8>>,
) -> Result<Self, StorageProofError>
pub fn new_with_duplicate_nodes_check( trie_nodes: impl IntoIterator<Item = Vec<u8>>, ) -> Result<Self, StorageProofError>
Constructs a storage proof from a subset of encoded trie nodes in a storage backend.
Returns an error if the provided subset of encoded trie nodes contains duplicates.
sourcepub fn empty() -> Self
pub fn empty() -> Self
Returns a new empty proof.
An empty proof is capable of only proving trivial statements (ie. that an empty set of key-value pairs exist in storage).
sourcepub fn into_iter_nodes(self) -> impl Sized + DoubleEndedIterator<Item = Vec<u8>>
pub fn into_iter_nodes(self) -> impl Sized + DoubleEndedIterator<Item = Vec<u8>>
Convert into an iterator over encoded trie nodes in lexicographical order constructed from the proof.
sourcepub fn iter_nodes(&self) -> impl Sized + DoubleEndedIterator<Item = &Vec<u8>>
pub fn iter_nodes(&self) -> impl Sized + DoubleEndedIterator<Item = &Vec<u8>>
Create an iterator over encoded trie nodes in lexicographical order constructed from the proof.
sourcepub fn into_nodes(self) -> BTreeSet<Vec<u8>>
pub fn into_nodes(self) -> BTreeSet<Vec<u8>>
Convert into plain node vector.
sourcepub fn into_memory_db<H: Hasher>(self) -> MemoryDB<H>
pub fn into_memory_db<H: Hasher>(self) -> MemoryDB<H>
Creates a MemoryDB
from Self
.
sourcepub fn to_memory_db<H: Hasher>(&self) -> MemoryDB<H>
pub fn to_memory_db<H: Hasher>(&self) -> MemoryDB<H>
Creates a MemoryDB
from Self
reference.
sourcepub fn merge(proofs: impl IntoIterator<Item = Self>) -> Self
pub fn merge(proofs: impl IntoIterator<Item = Self>) -> Self
Merges multiple storage proofs covering potentially different sets of keys into one proof covering all keys. The merged proof output may be smaller than the aggregate size of the input proofs due to deduplication of trie nodes.
sourcepub fn into_compact_proof<H: Hasher>(
self,
root: H::Out,
) -> Result<CompactProof, CompactProofError<H::Out, Error<H::Out>>>
pub fn into_compact_proof<H: Hasher>( self, root: H::Out, ) -> Result<CompactProof, CompactProofError<H::Out, Error<H::Out>>>
Encode as a compact proof with default trie layout.
sourcepub fn to_compact_proof<H: Hasher>(
&self,
root: H::Out,
) -> Result<CompactProof, CompactProofError<H::Out, Error<H::Out>>>
pub fn to_compact_proof<H: Hasher>( &self, root: H::Out, ) -> Result<CompactProof, CompactProofError<H::Out, Error<H::Out>>>
Encode as a compact proof with default trie layout.
Trait Implementations§
source§impl Clone for StorageProof
impl Clone for StorageProof
source§fn clone(&self) -> StorageProof
fn clone(&self) -> StorageProof
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for StorageProof
impl Debug for StorageProof
source§impl Decode for StorageProof
impl Decode for StorageProof
source§fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<Self, Error>
fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy, ) -> Result<Self, Error>
source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
source§impl Encode for StorageProof
impl Encode for StorageProof
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
source§fn using_encoded<__CodecOutputReturn, __CodecUsingEncodedCallback: FnOnce(&[u8]) -> __CodecOutputReturn>(
&self,
f: __CodecUsingEncodedCallback,
) -> __CodecOutputReturn
fn using_encoded<__CodecOutputReturn, __CodecUsingEncodedCallback: FnOnce(&[u8]) -> __CodecOutputReturn>( &self, f: __CodecUsingEncodedCallback, ) -> __CodecOutputReturn
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl<H: Hasher> From<&StorageProof> for MemoryDB<H>
impl<H: Hasher> From<&StorageProof> for MemoryDB<H>
source§fn from(proof: &StorageProof) -> Self
fn from(proof: &StorageProof) -> Self
source§impl<H: Hasher> From<StorageProof> for MemoryDB<H>
impl<H: Hasher> From<StorageProof> for MemoryDB<H>
source§fn from(proof: StorageProof) -> Self
fn from(proof: StorageProof) -> Self
source§impl PartialEq for StorageProof
impl PartialEq for StorageProof
source§fn eq(&self, other: &StorageProof) -> bool
fn eq(&self, other: &StorageProof) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl TypeInfo for StorageProof
impl TypeInfo for StorageProof
impl EncodeLike for StorageProof
impl Eq for StorageProof
impl StructuralPartialEq for StorageProof
Auto Trait Implementations§
impl Freeze for StorageProof
impl RefUnwindSafe for StorageProof
impl Send for StorageProof
impl Sync for StorageProof
impl Unpin for StorageProof
impl UnwindSafe for StorageProof
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> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
.