pub fn create(leaves: &[Vec<u8>]) -> MerkleTree<D> {
        let n = leaves.len();
        assert!(n > 0, "MerkleTree::create() called with no leaves");

        let num_nodes = n + n.next_power_of_two() - 1;

        let mut nodes = vec![vec![0u8]; num_nodes];

        for i in 0..leaves.len() {
            nodes[num_nodes - n + i] = D::digest(&leaves[i].clone()).to_vec();
        }

        for i in (0..num_nodes - n).rev() {
            let z = D::digest(&[0u8]).to_vec();
            let left = if left_child(i) < num_nodes {
                &nodes[left_child(i)]
            } else {
                &z
            };
            let right = if right_child(i) < num_nodes {
                &nodes[right_child(i)]
            } else {
                &z
            };
            nodes[i] = D::new().chain(left).chain(right).finalize().to_vec();
        }

        Self {
            nodes,
            n,
            leaf_off: num_nodes - n,
            hasher: PhantomData::default(),
        }
    }
/// Provide a non-empty list of leaves, `create` generate its corresponding `MerkleTree`.
Provide a non-empty list of leaves, `create` generate its corresponding `MerkleTree`.
Provide a non - empty list of leaves ` create ` generate its corresponding ` MerkleTree ` .
pub fn create(leaves: &[Vec<u8>]) -> MerkleTree<D> {
        let n = leaves.len();
        assert!(n > 0, "MerkleTree::create() called with no leaves");
        let num_nodes = n + n.next_power_of_two() - 1;
        let mut nodes = vec![vec![0u8]; num_nodes];
        for i in 0..leaves.len() {
            nodes[num_nodes - n + i] = D::digest(&leaves[i].clone()).to_vec();
        }
        for i in (0..num_nodes - n).rev() {
            let z = D::digest(&[0u8]).to_vec();
            let left = if left_child(i) < num_nodes {
                &nodes[left_child(i)]
            } else {
                &z
            };
            let right = if right_child(i) < num_nodes {
                &nodes[right_child(i)]
            } else {
                &z
            };
            nodes[i] = D::new().chain(left).chain(right).finalize().to_vec();
        }
        Self {
            nodes,
            n,
            leaf_off: num_nodes - n,
            hasher: PhantomData::default(),
        }
    }
pub fn create ( leaves : & [ Vec < u8 > ] ) -> MerkleTree < D > { let n = leaves . len ( ) ; assert ! ( n 0 " " ) ; let num_nodes = n + n . next_power_of_two ( ) - 1 ; let mut nodes = vec ! [ vec [ 0u8 ] num_nodes ] ; for i in 0 .. leaves . len ( ) { nodes [ num_nodes - n + i ] = D :: digest ( & leaves [ i ] . clone ( ) ) . to_vec ( ) ; } for i in ( 0 .. num_nodes - n ) . rev ( ) { let z = D :: digest ( & [ 0u8 ] ) . to_vec ( ) ; let left = if left_child ( i ) < num_nodes { & nodes [ left_child ( i ) ] } else { & z } ; let right = if right_child ( i ) < num_nodes { & nodes [ right_child ( i ) ] } else { & z } ; nodes [ i ] = D :: new ( ) . chain ( left ) . chain ( right ) . finalize ( ) . to_vec ( ) ; } Self { nodes , n , leaf_off : num_nodes - n , hasher : PhantomData :: default ( ) , } }
Provide a non-empty list of leaves, `create` generate its corresponding `MerkleTree`.
Provide a non - empty list of leaves ` create ` generate its corresponding ` MerkleTree ` .
leaves
&[Vec<u8>]