[][src]Struct smt_map::SmtMap256

pub struct SmtMap256 { /* fields omitted */ }

SmtMap256 is Sparse Merkle Tree Map from uint256 keys to uint256 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 (starting from the most-significant-bit to the least-significant-bit; 0 is left, 1 is right). The value is stored as the hash of the leaf node (in big-endian).

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 of uint256 where all keys have the default value (zero).

pub fn set(&mut self, key: U256, value: U256) -> U256
[src]

Sets the value of a key. Returns the old value of the key.

pub fn get(&self, key: &U256) -> &U256
[src]

Returns a reference to the value of a key.

pub fn get_with_proof(&self, key: &U256) -> (&U256, 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 verify_merkle_proof(
    &self,
    key: &U256,
    value: &U256,
    proof: &MerkleProof
) -> bool
[src]

Verifies the value of a key using the merkle proof. Returns whether the verification passed.

Auto Trait Implementations

impl Send for SmtMap256

impl Sync for SmtMap256

Blanket Implementations

impl<T> From for T
[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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