fn compute_root_hash(frozen_subtree_roots: &[HashValue], num_leaves: u64) -> HashValue {
        match frozen_subtree_roots.len() {
            0 => return *ACCUMULATOR_PLACEHOLDER_HASH,
            1 => return frozen_subtree_roots[0],
            _ => (),
        }

        // The trailing zeros do not matter since anything below the lowest frozen subtree is
        // already represented by the subtree roots.
        let mut bitmap = num_leaves >> num_leaves.trailing_zeros();
        let mut current_hash = *ACCUMULATOR_PLACEHOLDER_HASH;
        let mut frozen_subtree_iter = frozen_subtree_roots.iter().rev();

        while bitmap > 0 {
            current_hash = if bitmap & 1 != 0 {
                MerkleTreeInternalNode::<H>::new(
                    *frozen_subtree_iter
                        .next()
                        .expect("This frozen subtree should exist."),
                    current_hash,
                )
            } else {
                MerkleTreeInternalNode::<H>::new(current_hash, *ACCUMULATOR_PLACEHOLDER_HASH)
            }
            .hash();
            bitmap >>= 1;
        }

        current_hash
    }
/// Computes the root hash of an accumulator given the frozen subtree roots and the number of
/// leaves in this accumulator.
Computes the root hash of an accumulator given the frozen subtree roots and the number of
leaves in this accumulator.
Computes the root hash of an accumulator given the frozen subtree roots and the number of leaves in this accumulator .
fn compute_root_hash(frozen_subtree_roots: &[HashValue], num_leaves: u64) -> HashValue {
        match frozen_subtree_roots.len() {
            0 => return *ACCUMULATOR_PLACEHOLDER_HASH,
            1 => return frozen_subtree_roots[0],
            _ => (),
        }
        // The trailing zeros do not matter since anything below the lowest frozen subtree is
        // already represented by the subtree roots.
        let mut bitmap = num_leaves >> num_leaves.trailing_zeros();
        let mut current_hash = *ACCUMULATOR_PLACEHOLDER_HASH;
        let mut frozen_subtree_iter = frozen_subtree_roots.iter().rev();
        while bitmap > 0 {
            current_hash = if bitmap & 1 != 0 {
                MerkleTreeInternalNode::<H>::new(
                    *frozen_subtree_iter
                        .next()
                        .expect("This frozen subtree should exist."),
                    current_hash,
                )
            } else {
                MerkleTreeInternalNode::<H>::new(current_hash, *ACCUMULATOR_PLACEHOLDER_HASH)
            }
            .hash();
            bitmap >>= 1;
        }
        current_hash
    }
fn compute_root_hash ( frozen_subtree_roots : & [ HashValue ] , num_leaves : u64 ) -> HashValue { match frozen_subtree_roots . len ( ) { 0 => return * ACCUMULATOR_PLACEHOLDER_HASH , 1 => return frozen_subtree_roots [ 0 ] , _ => ( ) , } // The trailing zeros do not matter since anything below the lowest frozen subtree is // already represented by the subtree roots. let mut bitmap = num_leaves >> num_leaves . trailing_zeros ( ) ; let mut current_hash = * ACCUMULATOR_PLACEHOLDER_HASH ; let mut frozen_subtree_iter = frozen_subtree_roots . iter ( ) . rev ( ) ; while bitmap > 0 { current_hash = if bitmap & 1 != 0 { MerkleTreeInternalNode :: < H > :: new ( * frozen_subtree_iter . next ( ) . expect ( " " ) , current_hash , ) } else { MerkleTreeInternalNode :: < H > :: new ( current_hash , * ACCUMULATOR_PLACEHOLDER_HASH ) } . hash ( ) ; bitmap >>= 1 ; } current_hash }
Computes the root hash of an accumulator given the frozen subtree roots and the number of
leaves in this accumulator.
Computes the root hash of an accumulator given the frozen subtree roots and the number of leaves in this accumulator .
frozen_subtree_roots
&[HashValue]
num_leaves
u64
frozen_subtree_roots
&[HashValue]
num_leaves
u64