Skip to content

Commit

Permalink
chore(offchain): remove counting trick inherited from lua code
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenctw committed Jan 8, 2024
1 parent 5aa73c9 commit dbe45cd
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions offchain/core/src/merkle/tree_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,9 @@ impl MerkleBuilder {
pub fn build(&mut self) -> MerkleTree {
let last = self.leafs.last().expect("no leafs in merkle builder");
let count = last.accumulated_count;
let mut log2_size = 64;

if count != 0 {
assert!(count.is_power_of_two(), "is not a power of two {}", count);
log2_size = count.trailing_zeros();
};
assert!(count.is_power_of_two(), "is not a power of two {}", count);
let log2_size = count.trailing_zeros();

let leafs_clone = self.leafs.clone();
let root = self.build_merkle(leafs_clone.as_slice(), log2_size, 0);
Expand Down

0 comments on commit dbe45cd

Please sign in to comment.