Skip to content

Commit

Permalink
set_subtree: return root
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Dec 5, 2023
1 parent 95417f2 commit 4630169
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/merkle/simple_smt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RpoDigest, MerkleError> {
if subtree.depth() > self.depth() {
return Err(MerkleError::InvalidSubtreeDepth {
subtree_depth: subtree.depth(),
Expand Down Expand Up @@ -298,7 +300,7 @@ impl SimpleSmt {
// --------------
self.recompute_nodes_from_index_to_root(subtree_root_index, subtree.root);

Ok(())
Ok(self.root)
}

// HELPER METHODS
Expand Down

0 comments on commit 4630169

Please sign in to comment.