-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement SimpleSmt::set_subtree
#232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you!
Note that
set_subtree()
returnsResult<(), MerkleError>
instead ofResult<(), MerkleError>
, because I didn't know which value to return.
I was thinking we'd return the new root.
I would also suggest we change the interface to
pub fn set_subtree(&mut self, index: NodeIndex, subtree: SimpleSmt) -> Result<(), MerkleError>This would result in caller code that's easier to read (since the depth of the insertion is determined at the call site). I believe callers should always know the depth at which they want to insert, such as in
miden-node
where we want to insert a subtree of depth 13 at depth 8.
I don't mind this change, but I do think that having to construct NodeIndex
might complicate the interface a bit. But not a strong opinion by any means.
Kudos, SonarCloud Quality Gate passed! |
Changed it return the root (as an |
Closes #220
Note that
set_subtree()
returnsResult<(), MerkleError>
instead ofResult<Word, MerkleError>
, because I didn't know which value to return. The hash of the internal node where the subtree root was inserted? Is this relevant information?I would also suggest we change the interface to
This would result in caller code that's easier to read (since the depth of the insertion is determined at the call site). I believe callers should always know the depth at which they want to insert, such as in
miden-node
where we want to insert a subtree of depth 13 at depth 8.