Skip to content
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

compact: Simplify getting hashes in NewTreeWithState #1618

Merged
merged 2 commits into from
May 20, 2019

Conversation

pav-kv
Copy link
Contributor

@pav-kv pav-kv commented May 20, 2019

This change factors out getting the list of node IDs needed to initialize compact.Tree
into a separate exported function.

This eliminates GetNodesFunc callback which makes client code simpler, and also
allows a more direct initialization of compact.Range.

@codecov
Copy link

codecov bot commented May 20, 2019

Codecov Report

Merging #1618 into master will increase coverage by 0.01%.
The diff coverage is 84.37%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1618      +/-   ##
=========================================
+ Coverage   66.89%   66.9%   +0.01%     
=========================================
  Files         110     110              
  Lines        8946    8943       -3     
=========================================
- Hits         5984    5983       -1     
+ Misses       2358    2357       -1     
+ Partials      604     603       -1
Impacted Files Coverage Δ
merkle/compact/tree.go 91.54% <100%> (+2.36%) ⬆️
log/sequencer.go 74.89% <77.27%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c3b56b5...be5b5b7. Read the comment docs.

@codecov
Copy link

codecov bot commented May 20, 2019

Codecov Report

Merging #1618 into master will increase coverage by 0.01%.
The diff coverage is 84.37%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1618      +/-   ##
=========================================
+ Coverage   66.89%   66.9%   +0.01%     
=========================================
  Files         110     110              
  Lines        8946    8943       -3     
=========================================
- Hits         5984    5983       -1     
+ Misses       2358    2357       -1     
+ Partials      604     603       -1
Impacted Files Coverage Δ
merkle/compact/tree.go 91.54% <100%> (+2.36%) ⬆️
log/sequencer.go 74.89% <77.27%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c3b56b5...ece5c90. Read the comment docs.

@pav-kv pav-kv requested a review from Martin2112 May 20, 2019 13:35
log/sequencer.go Show resolved Hide resolved
}
// Note: Right border nodes of compact.Range are ordered from root to leaves.
for i, j := 0, len(ids)-1; i < j; i, j = i+1, j-1 {
ids[i], ids[j] = ids[j], ids[i]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought but we could add the other ordering to Range if reversal is going to crop up a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thought, we'll see if/when another use-case appears. That wouldn't be a trivial change though. Range implementation has a very specific ordering: hashes slice contains 2 stacks of hashes - the front one is ordered bottom-to-top, the back one is ordered top-to-bottom. Stack ordering comes handy when 2 ranges are merged, so that the slice is mutated with minimal copies/reallocations.

@pav-kv pav-kv merged commit 4c202cf into google:master May 20, 2019
@pav-kv pav-kv deleted the direct_get_hashes branch May 20, 2019 14:52
gdbelvin added a commit that referenced this pull request May 23, 2019
* master: (94 commits)
  Complete TODO (#1632)
  fake_node_reader: Remove unused field (#1631)
  Parallelize VerifyMapLeavesResponse (#1615)
  Remove redundant root hash calculations (#1630)
  sequencer: Consolidate compact.Tree initialization (#1629)
  Remove unused NodeReader method (#1625)
  Fix bazel build (#1627)
  added/updated postgresql implementation of log_storage (#1571)
  Clean up compact.Tree tests (#1622)
  Remove old hash list format from compact.Tree (#1621)
  Mention protoc-gen-doc in README.md
  merkle: Add testonly package with golden hashes (#1620)
  compact: Simplify getting hashes in NewTreeWithState (#1618)
  compact: Implement Tree using Range (#1522)
  Guard verbose logging in merkle path code (#1604)
  Make MaskLeft of NodeID return an explicit copy. (#1612)
  Convert directly from Int.Bits() to NodeID (#1614)
  Couple of changes to make NodeIDs more frugal. (#1613)
  compact.Tree: Change semantic of adding leaves (#1592)
  MapHasher: Do not return error from HashLeaf (#1611)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants