Skip to content

Commit

Permalink
document & clarify is_descendant_pos
Browse files Browse the repository at this point in the history
  • Loading branch information
Lederstrumpf committed Mar 26, 2024
1 parent 7749d1f commit 14edd7c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ pub fn get_peak_map(mmr_size: u64) -> u64 {
peak_map
}

/// Returns whether `descendant_contender` is a descendant of `ancestor_contender` in a tree of the MMR.
pub fn is_descendant_pos(ancestor_contender: u64, descendant_contender: u64) -> bool {
// NOTE: "ancestry" here refers to the hierarchy within an MMR tree, not temporal hierarchy.
// the descendant needs to have been added to the mmr prior to the ancestor
descendant_contender <= ancestor_contender
// the descendant needs to be within the cone of positions descendant from the ancestor
&& descendant_contender
>= (ancestor_contender + 1 - sibling_offset(pos_height_in_tree(ancestor_contender)))
}
Expand Down

0 comments on commit 14edd7c

Please sign in to comment.