[][src]Struct scratchpad::SparseMerkleTree

pub struct SparseMerkleTree { /* fields omitted */ }

The Sparse Merkle Tree implementation.

Implementations

impl SparseMerkleTree[src]

pub fn new(root_hash: HashValue) -> Self[src]

Constructs a Sparse Merkle Tree with a root hash. This is often used when we restart and the scratch pad and the storage have identical state, so we use a single root hash to represent the entire state.

pub fn update(
    &self,
    updates: Vec<(HashValue, AccountStateBlob)>,
    proof_reader: &impl ProofRead
) -> Result<Self, UpdateError>
[src]

Constructs a new Sparse Merkle Tree as if we are updating the existing tree. Since the tree is immutable, the existing tree will remain the same and may share part of the tree with the new one.

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

Queries a key in this SparseMerkleTree.

pub fn root_hash(&self) -> HashValue[src]

Returns the root hash of this tree.

pub fn prune(&self)[src]

Prunes a tree by replacing every node reachable from root with a subtree node that has the same hash. If a node is empty or a subtree, we don't need to do anything. For example in the following case, if we drop S_i, we will replace o with a subtree node, then o no longer has pointers to its children x and A, so they will be dropped automatically.

           S_i        S_{i+1}                               S_{i+1}
          /   \      /       \                             /       \
         /     y   /          \          drop(S_i)        o         y'
        / _______/             \         ========>                 / \
       //                       \                                 z   B
      o                          y'
     / \                        / \
    x   A                      z   B

Trait Implementations

impl Debug for SparseMerkleTree[src]

impl Default for SparseMerkleTree[src]

Auto Trait Implementations

impl RefUnwindSafe for SparseMerkleTree

impl Send for SparseMerkleTree

impl Sync for SparseMerkleTree

impl Unpin for SparseMerkleTree

impl UnwindSafe for SparseMerkleTree

Blanket Implementations

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

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

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

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

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

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

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> 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<V, T> VZip<V> for T where
    V: MultiLane<T>,