-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(plonky2x):
get_root_from_hashed_leaves
(#282)
- Loading branch information
1 parent
5fb0b3b
commit fcf983d
Showing
4 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod tendermint; | ||
pub mod tree; | ||
pub mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// Computes the ceiling of the base 2 log of a `usize`. | ||
pub fn log2_ceil_usize(x: usize) -> usize { | ||
if x <= 1 { | ||
// log2(0) and log2(1) are both 0. | ||
return 0; | ||
} | ||
|
||
let mut result = 0; | ||
// Subtract 1 to ensure rounding up for powers of 2. | ||
let mut value = x - 1; | ||
|
||
while value > 0 { | ||
value >>= 1; | ||
result += 1; | ||
} | ||
|
||
result as usize | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters