Struct diem_types::proof::definition::SparseMerkleProof
source · pub struct SparseMerkleProof<V> { /* private fields */ }
Expand description
A proof that can be used to authenticate an element in a Sparse Merkle Tree given trusted root
hash. For example, TransactionInfoToAccountProof
can be constructed on top of this structure.
Implementations§
source§impl<V> SparseMerkleProof<V>where
V: CryptoHash,
impl<V> SparseMerkleProof<V>where V: CryptoHash,
sourcepub fn new(leaf: Option<SparseMerkleLeafNode>, siblings: Vec<HashValue>) -> Self
pub fn new(leaf: Option<SparseMerkleLeafNode>, siblings: Vec<HashValue>) -> Self
Constructs a new SparseMerkleProof
using leaf and a list of siblings.
sourcepub fn leaf(&self) -> Option<SparseMerkleLeafNode>
pub fn leaf(&self) -> Option<SparseMerkleLeafNode>
Returns the leaf node in this proof.
sourcepub fn verify(
&self,
expected_root_hash: HashValue,
element_key: HashValue,
element_value: Option<&V>
) -> Result<()>
pub fn verify( &self, expected_root_hash: HashValue, element_key: HashValue, element_value: Option<&V> ) -> Result<()>
If element_value
is present, verifies an element whose key is element_key
and value is
element_value
exists in the Sparse Merkle Tree using the provided proof. Otherwise
verifies the proof is a valid non-inclusion proof that shows this key doesn’t exist in the
tree.
Trait Implementations§
source§impl<V> Arbitrary for SparseMerkleProof<V>where
V: Debug + CryptoHash,
impl<V> Arbitrary for SparseMerkleProof<V>where V: Debug + CryptoHash,
§type Parameters = ()
type Parameters = ()
The type of parameters that
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.§type Strategy = BoxedStrategy<SparseMerkleProof<V>>
type Strategy = BoxedStrategy<SparseMerkleProof<V>>
The type of
Strategy
used to generate values of type Self
.source§fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy
source§impl<V: Clone> Clone for SparseMerkleProof<V>
impl<V: Clone> Clone for SparseMerkleProof<V>
source§fn clone(&self) -> SparseMerkleProof<V>
fn clone(&self) -> SparseMerkleProof<V>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<V: Debug> Debug for SparseMerkleProof<V>
impl<V: Debug> Debug for SparseMerkleProof<V>
source§impl<'de, V> Deserialize<'de> for SparseMerkleProof<V>
impl<'de, V> Deserialize<'de> for SparseMerkleProof<V>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<V: PartialEq> PartialEq<SparseMerkleProof<V>> for SparseMerkleProof<V>
impl<V: PartialEq> PartialEq<SparseMerkleProof<V>> for SparseMerkleProof<V>
source§fn eq(&self, other: &SparseMerkleProof<V>) -> bool
fn eq(&self, other: &SparseMerkleProof<V>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<V> Serialize for SparseMerkleProof<V>
impl<V> Serialize for SparseMerkleProof<V>
impl<V: Eq> Eq for SparseMerkleProof<V>
impl<V> StructuralEq for SparseMerkleProof<V>
impl<V> StructuralPartialEq for SparseMerkleProof<V>
Auto Trait Implementations§
impl<V> RefUnwindSafe for SparseMerkleProof<V>where V: RefUnwindSafe,
impl<V> Send for SparseMerkleProof<V>where V: Send,
impl<V> Sync for SparseMerkleProof<V>where V: Sync,
impl<V> Unpin for SparseMerkleProof<V>where V: Unpin,
impl<V> UnwindSafe for SparseMerkleProof<V>where V: UnwindSafe,
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> TestOnlyHash for Twhere
T: Serialize + ?Sized,
impl<T> TestOnlyHash for Twhere T: Serialize + ?Sized,
source§fn test_only_hash(&self) -> HashValue
fn test_only_hash(&self) -> HashValue
Generates a hash used only for tests.