-
Notifications
You must be signed in to change notification settings - Fork 263
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
fix: remove RangeProofs
#586
Changes from 1 commit
01890c8
8dce332
91ad406
7db6e22
a87b7b6
31bab40
7a7dfca
bd9353b
87cbe24
3f1d232
9c9915c
fa0d2b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,16 +179,12 @@ func convertVarIntToBytes(orig int64, buf [binary.MaxVarintLen64]byte) []byte { | |
return buf[:n] | ||
} | ||
|
||
// GetWithProof gets the proof for the given key. | ||
func (t *ImmutableTree) GetWithProof(key []byte) (*ics23.CommitmentProof, error) { | ||
// GetProof gets the proof for the given key. | ||
func (t *ImmutableTree) GetProof(key []byte, isExist bool) (*ics23.CommitmentProof, error) { | ||
if t.root == nil { | ||
return nil, fmt.Errorf("cannot generate the proof with nil root") | ||
} | ||
value, err := t.Get(key) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if value != nil { | ||
if isExist { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry for not being more specific, I think you can use the exist, err := t.Has(key)
if err != nil {
return nil, err
}
if exist {
return t.GetMembershipProof(key)
}
return t.GetNonMembershipProof(key) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, it's a simple solution but I'd like to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess when the SDK queries for this value, it should be performing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I think it would be related to each use case, here my purpose is to reduce checks in the |
||
return t.GetMembershipProof(key) | ||
} | ||
return t.GetNonMembershipProof(key) | ||
|
@@ -202,14 +198,14 @@ func (t *ImmutableTree) VerifyProof(proof *ics23.CommitmentProof, key []byte) (b | |
return t.VerifyNonMembership(proof, key) | ||
} | ||
|
||
// GetVersionedWithProof gets the proof for the given key at the specified version. | ||
func (tree *MutableTree) GetVersionedWithProof(key []byte, version int64) (*ics23.CommitmentProof, error) { | ||
// GetVersionedProof gets the proof for the given key at the specified version. | ||
func (tree *MutableTree) GetVersionedProof(key []byte, isExist bool, version int64) (*ics23.CommitmentProof, error) { | ||
if tree.VersionExists(version) { | ||
t, err := tree.GetImmutable(version) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return t.GetWithProof(key) | ||
return t.GetProof(key, isExist) | ||
} | ||
return nil, ErrVersionDoesNotExist | ||
} |
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.
Seems weird to me that we would expose the API to take in an
isExist
bool.Doesn't it make more sense to just check if key exists in the tree.
If it does, return an existence proof otherwise return a nonexistence proof