diff --git a/src/merkle/index.rs b/src/merkle/index.rs index 104ceb44..24b38089 100644 --- a/src/merkle/index.rs +++ b/src/merkle/index.rs @@ -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 // --------------------------------------------------------------------------------------------