Skip to content

Commit

Permalink
merkle: add parent() helper function on NodeIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
Qyriad committed Oct 22, 2024
1 parent 9133846 commit 04dbbf9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/merkle/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ impl NodeIndex {
self
}

/// Returns the parent of the current node. This is the same as [`Self::move_up()`], but returns
/// a new value instead of mutating `self`.
pub const fn parent(mut self) -> Self {
self.depth = self.depth.saturating_sub(1);
self.value >>= 1;
self
}

// PROVIDERS
// --------------------------------------------------------------------------------------------

Expand Down

0 comments on commit 04dbbf9

Please sign in to comment.