From 4630169e3d640564b0b26ff9e877f76e9f83137a Mon Sep 17 00:00:00 2001 From: Philippe Laferriere Date: Tue, 5 Dec 2023 09:24:33 -0500 Subject: [PATCH] set_subtree: return root --- src/merkle/simple_smt/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/merkle/simple_smt/mod.rs b/src/merkle/simple_smt/mod.rs index 3b40893b..4ce94a41 100644 --- a/src/merkle/simple_smt/mod.rs +++ b/src/merkle/simple_smt/mod.rs @@ -245,11 +245,13 @@ impl SimpleSmt { /// Inserts a subtree at the specified index. The depth at which the subtree is inserted is /// computed as `self.depth() - subtree.depth()`. + /// + /// Returns the new root. pub fn set_subtree( &mut self, subtree_insertion_index: u64, subtree: SimpleSmt, - ) -> Result<(), MerkleError> { + ) -> Result { if subtree.depth() > self.depth() { return Err(MerkleError::InvalidSubtreeDepth { subtree_depth: subtree.depth(), @@ -298,7 +300,7 @@ impl SimpleSmt { // -------------- self.recompute_nodes_from_index_to_root(subtree_root_index, subtree.root); - Ok(()) + Ok(self.root) } // HELPER METHODS