Skip to content

Commit

Permalink
Fix: change version handling in query membership
Browse files Browse the repository at this point in the history
  • Loading branch information
gdiazlo committed Mar 7, 2019
1 parent 9af6ac7 commit 6d52272
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions balloon/balloon.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ func (b Balloon) QueryDigestMembership(keyDigest hashing.Digest, version uint64)
proof.KeyDigest = keyDigest
proof.QueryVersion = version
proof.CurrentVersion = b.version - 1

if version > b.version {
version = b.version
}
leaf, err := b.store.Get(storage.IndexPrefix, proof.KeyDigest)
if err != nil {
return nil, fmt.Errorf("No leaf with digest %v", proof.KeyDigest)
Expand All @@ -264,14 +266,14 @@ func (b Balloon) QueryDigestMembership(keyDigest hashing.Digest, version uint64)
proof.Exists = true
proof.ActualVersion = util.BytesAsUint64(leaf.Value)

if proof.ActualVersion <= proof.QueryVersion {
if proof.ActualVersion <= version {
wg.Add(1)
go func() {
defer wg.Done()
historyProof, historyErr = b.historyTree.ProveMembership(proof.ActualVersion, proof.QueryVersion)
historyProof, historyErr = b.historyTree.ProveMembership(proof.ActualVersion, version)
}()
} else {
return nil, fmt.Errorf("Query version %d is not on history tree which version is %d", proof.QueryVersion, proof.ActualVersion)
return nil, fmt.Errorf("Query version %d is not on history tree which version is %d", version, proof.ActualVersion)
}

hyperProof, hyperErr = b.hyperTree.QueryMembership(leaf.Key, leaf.Value)
Expand Down

0 comments on commit 6d52272

Please sign in to comment.