Merge pull request #80 from zingolabs/clarify_position_is_leaf

Fix doc comments to clarify that positions are always leaves, not inner nodes
This commit is contained in:
Kris Nuttycombe 2023-07-05 14:02:54 -06:00 committed by GitHub
commit 8c927ce11e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -144,13 +144,13 @@ impl Position {
}
/// Returns the minimum possible level of the root of a binary tree containing at least
/// `self + 1` nodes.
/// `self + 1` leaves.
pub fn root_level(&self) -> Level {
Level((u64::BITS - self.0.leading_zeros()) as u8)
}
/// Returns the number of cousins and/or ommers required to construct an authentication
/// path to the root of a merkle tree that has `self + 1` nodes.
/// path to the root of a merkle tree that has `self + 1` leaves.
pub fn past_ommer_count(&self) -> u8 {
(0..self.root_level().0)
.filter(|i| (self.0 >> i) & 0x1 == 1)