Browse Source

Merkle tree panics when there's a single leaf - fix

master
Sergey Vasilyev 4 years ago
committed by Pratyush Mishra
parent
commit
0b87c84cdd
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      crypto-primitives/src/merkle_tree/mod.rs

+ 4
- 0
crypto-primitives/src/merkle_tree/mod.rs

@ -268,6 +268,10 @@ fn log2(number: usize) -> usize {
/// Returns the height of the tree, given the size of the tree. /// Returns the height of the tree, given the size of the tree.
#[inline] #[inline]
fn tree_height(tree_size: usize) -> usize { fn tree_height(tree_size: usize) -> usize {
if tree_size == 1 {
return 1;
}
log2(tree_size) log2(tree_size)
} }

Loading…
Cancel
Save