[][src]Struct smt_map::SmtMap256

pub struct SmtMap256 { /* fields omitted */ }

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]

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_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Default for SmtMap256[src]

Auto Trait Implementations

impl Send for SmtMap256

impl Sync for SmtMap256

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.