pub fn new_with_leaf(tree_depth: Depth, default_leaf: T) -> Self {
        let hasher = H::default();

        // we need to make sparse hashes for tree depth levels
        let mut prehashed = Vec::with_capacity((tree_depth + 1) as usize);
        let mut cur = hasher.hash_bits(default_leaf.get_bits_le());
        prehashed.push(cur.clone());

        for i in 0..tree_depth {
            cur = hasher.compress(&cur, &cur, i as usize);
            prehashed.push(cur.clone());
        }
        prehashed.reverse();

        // print!("Made default hashes in quantity {}\n", prehashed.len());

        assert_eq!(prehashed.len() - 1, tree_depth as usize);
        Self {
            tree_depth,
            prehashed,
            items: HashMap::new(),
            hashes: HashMap::new(),
            hasher,
        }
    }
/// Creates a new tree with the default item provided.
/// This method is similar to `SparseMerkleTree::new`, but does not rely
/// on the `Default` trait implementation for `T`.
Creates a new tree with the default item provided.
Creates a new tree with the default item provided .
pub fn new_with_leaf(tree_depth: Depth, default_leaf: T) -> Self {
        let hasher = H::default();
        // we need to make sparse hashes for tree depth levels
        let mut prehashed = Vec::with_capacity((tree_depth + 1) as usize);
        let mut cur = hasher.hash_bits(default_leaf.get_bits_le());
        prehashed.push(cur.clone());
        for i in 0..tree_depth {
            cur = hasher.compress(&cur, &cur, i as usize);
            prehashed.push(cur.clone());
        }
        prehashed.reverse();
        // print!("Made default hashes in quantity {}\n", prehashed.len());
        assert_eq!(prehashed.len() - 1, tree_depth as usize);
        Self {
            tree_depth,
            prehashed,
            items: HashMap::new(),
            hashes: HashMap::new(),
            hasher,
        }
    }
pub fn new_with_leaf ( tree_depth : Depth , default_leaf : T ) -> Self { let hasher = H :: default ( ) ; // we need to make sparse hashes for tree depth levels let mut prehashed = Vec :: with_capacity ( ( tree_depth + 1 ) as usize ) ; let mut cur = hasher . hash_bits ( default_leaf . get_bits_le ( ) ) ; prehashed . push ( cur . clone ( ) ) ; for i in 0 .. tree_depth { cur = hasher . compress ( & cur , & cur , i as usize ) ; prehashed . push ( cur . clone ( ) ) ; } prehashed . reverse ( ) ; // print!("Made default hashes in quantity {}\n", prehashed.len()); assert_eq ! ( prehashed len ( ) 1 tree_depth as usize ) ; Self { tree_depth , prehashed , items : HashMap :: new ( ) , hashes : HashMap :: new ( ) , hasher , } }
Creates a new tree with the default item provided.
Creates a new tree with the default item provided .
tree_depth
Depth
default_leaf
T