-
Notifications
You must be signed in to change notification settings - Fork 15
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
Replace justified unwraps
in shardtree
with expect
s
#119
base: main
Are you sure you want to change the base?
Conversation
Rust 1.82 adds support for omitting empty types in pattern matching, which would make these much clearer.
@@ -406,13 +406,16 @@ impl< | |||
|
|||
/// Adds a checkpoint at the rightmost leaf state of the tree. | |||
pub fn checkpoint(&mut self, checkpoint_id: C) -> Result<bool, ShardTreeError<S::Error>> { | |||
/// Pre-condition: `root_addr` must be the address of `root`. |
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.
This pre-condition (and all similar others in this PR) is verifiably upheld:
- We call this method initially with
go(subtree.root_addr, &subtree.root)
; it is a programming error for these to be inconsistent. - We recurse by calling either
go(r_addr, right)
orgo(l_addr, left)
with values obtained fromroot_addr
androot
.
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.
it is a programming error for these to be inconsistent.
I note that the public API LocatedTree::from_parts
does not enforce that its arguments are consistent; we could potentially strengthen this by making that method fallible and checking that the actual encoded depth of the provided tree matches the provided root address (which would ensure that all parents within the provided tree correspond to a subtree node of the provided root address that can have children).
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.
I've updated this PR to add the consistency check to LocatedTree::from_parts
.
This ensures that the various existing `unwrap`s are correctly justified.
33e7aa1
to
166872e
Compare
// the authentication path on the way back up. | ||
/// Traverse down to the desired leaf position, and then construct | ||
/// the authentication path on the way back up. | ||
// |
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.
Non-blocking nit:
// | |
/// |
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.
I didn't think that ///
comments were allowed on internal documentation? I suspect this whole comment will produce a linting or doc error.
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.
utACK
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.
utACK modulo doc/comment linting c05f2fa
// the authentication path on the way back up. | ||
/// Traverse down to the desired leaf position, and then construct | ||
/// the authentication path on the way back up. | ||
// |
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.
I didn't think that ///
comments were allowed on internal documentation? I suspect this whole comment will produce a linting or doc error.
Part of #118.