-
Notifications
You must be signed in to change notification settings - Fork 381
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
} | ||
// 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] |
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.
Just a thought but we could add the other ordering to Range if reversal is going to crop up a lot.
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.
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.
* 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) ...
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 alsoallows a more direct initialization of
compact.Range
.