merkle: add parent() helper function on NodeIndex

This commit is contained in:
Qyriad 2024-10-22 17:16:38 -06:00
parent ee20a49953
commit 8e594963d2

View file

@ -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
// --------------------------------------------------------------------------------------------