From aa88e29f2cd574273af2c71e847312bb8ac1557d Mon Sep 17 00:00:00 2001 From: Qyriad Date: Wed, 16 Oct 2024 12:15:49 -0600 Subject: [PATCH] WIP: remove unused helpers for NodeIndex --- src/merkle/index.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/merkle/index.rs b/src/merkle/index.rs index cedc435..14d9165 100644 --- a/src/merkle/index.rs +++ b/src/merkle/index.rs @@ -193,26 +193,22 @@ impl NodeIndex { return false; } + if other.depth < self.depth { + return false; + } + other = other.parent(); } } - /// Returns the right-most descendent of the current node for a tree of `DEPTH` depth. - pub const fn rightmost_descendent(mut self) -> Self { - while self.depth() < DEPTH { - self = self.right_child(); - } - - self + /// The inverse of [`NodeIndex::is_ancestor_of`], except that it does not include itself. + pub fn is_descendent_of(self, other: Self) -> bool { + self.depth != other.depth && self.value != other.value && other.contains(self) } - /// Returns the left-most descendent of the current node for a tree of `DEPTH` depth. - pub const fn leftmost_descendent(mut self) -> Self { - while self.depth() < DEPTH { - self = self.left_child(); - } - - self + /// Returns `true` if and only if `other` is an ancestor of the current node. + pub fn is_ancestor_of(self, other: Self) -> bool { + self.depth != other.depth && self.value != other.value && self.contains(other) } // PROVIDERS