MerkleTree

Trait MerkleTree 

Source
pub trait MerkleTree<L: Serialize + DeserializeOwned + Clone + Debug + PartialEq, H: Hasher<L>> {
    // Required methods
    fn init(
        &self,
        storage: &mut dyn Storage,
        level: u8,
        default_leaf: L,
        hasher: &H,
    ) -> Result<(), MerkleTreeError>;
    fn is_valid_root(
        &self,
        storage: &dyn Storage,
        root: &L,
    ) -> Result<bool, MerkleTreeError>;
    fn insert(
        &self,
        storage: &mut dyn Storage,
        leaf: L,
        hasher: &H,
    ) -> Result<(u64, L), MerkleTreeError>;
    fn get_latest_root(
        &self,
        storage: &dyn Storage,
    ) -> Result<L, MerkleTreeError>;
}

Required Methods§

Source

fn init( &self, storage: &mut dyn Storage, level: u8, default_leaf: L, hasher: &H, ) -> Result<(), MerkleTreeError>

Initize the tree.

Source

fn is_valid_root( &self, storage: &dyn Storage, root: &L, ) -> Result<bool, MerkleTreeError>

Check if the root is valid for the tree.

Source

fn insert( &self, storage: &mut dyn Storage, leaf: L, hasher: &H, ) -> Result<(u64, L), MerkleTreeError>

Insert the leaf into the next index slot of the tree. Return the leaf’s index and the updated root.

Source

fn get_latest_root(&self, storage: &dyn Storage) -> Result<L, MerkleTreeError>

Get the latest root of the tree.

Implementors§

Source§

impl<'a, L: Serialize + DeserializeOwned + Clone + Debug + PartialEq + PrimaryKey<'a>, H: Hasher<L>> MerkleTree<L, H> for SparseMerkleTreeWithHistory<'a, L, H>

Source§

impl<'a, L: Serialize + DeserializeOwned + Clone + Debug + PartialEq + PrimaryKey<'a>, H: Hasher<L>, const HISTORY_LEVEL: u32> MerkleTree<L, H> for SparseMerkleTreeWithHistoryBounded<'a, L, H, HISTORY_LEVEL>

Source§

impl<'a, L: Serialize + DeserializeOwned + Clone + Debug + PartialEq, H: Hasher<L>> MerkleTree<L, H> for SparseMerkleTree<'a, L, H>