[−][src]Struct smt_map::SmtMap256
SmtMap256 is Sparse Merkle Tree Map from 256-bit keys to 256-bit values, and supports generating 256-bit merkle proofs. Initially every of the 2**256 possible keys has a default value of zero.
Each leaf corresponds to a key-value pair. The key is the bit-path from the root to the leaf (see the documentation for TreeNodeIndex).
The hash of the leaf node is just the value of the corresponding key. The hash of an non-leaf node is calculated by hashing (using keccak-256) the concatenation of the hashes of its two sub-nodes.
Methods
impl SmtMap256
[src]
pub fn new() -> Self
[src]
Returns a new SMT-Map where all keys have the default value (zero).
pub fn set(&mut self, key: &Key, value: Value) -> Value
[src]
Sets the value of a key. Returns the old value of the key.
pub fn get(&self, key: &Key) -> &Value
[src]
Returns a reference to the value of a key.
pub fn get_with_proof(&self, key: &Key) -> (&Value, MerkleProof)
[src]
Returns a reference to the value of the key with merkle proof.
pub fn merkle_root(&self) -> &Hash256
[src]
Returns the merkle root of this Sparse Merkle Tree.
pub fn check_merkle_proof(
&self,
key: &Key,
value: &Value,
proof: &MerkleProof
) -> bool
[src]
&self,
key: &Key,
value: &Value,
proof: &MerkleProof
) -> bool
Check the merkle proof of a key-value pair in this SMT-Map. Returns whether the proof is valid.
Trait Implementations
impl Clone for SmtMap256
[src]
fn clone(&self) -> SmtMap256
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for SmtMap256
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.