Clarify calculation of block ranges

This commit is contained in:
Jack Grigg 2020-03-04 09:15:15 +13:00 committed by Daira Hopwood
parent 6d64ce0c87
commit c8193992d4
1 changed files with 5 additions and 5 deletions

View File

@ -452,7 +452,7 @@ With each new block ``B_n``, we append a new MMR leaf node corresponding to bloc
peaks: List[ZcashMMRNode] = []
# Get number of leaves.
leaves = latest_height - earliest_height + 1
leaves = latest_height - (earliest_height - 1)
# Check if the number of leaves is a power of two.
if (leaves & (leaves - 1)) == 0:
@ -488,8 +488,8 @@ With each new block ``B_n``, we append a new MMR leaf node corresponding to bloc
# This will produce a list of peaks in reverse order
current = leaf
for peak in peaks[::-1]:
current_leaves = current.latest_height - current.earliest_height + 1
peak_leaves = peak.latest_height - peak.earliest_height + 1
current_leaves = current.latest_height - (current.earliest_height - 1)
peak_leaves = peak.latest_height - (peak.earliest_height - 1)
if current_leaves == peak_leaves:
current = make_parent(peak, current)
@ -513,7 +513,7 @@ in the right subtree of the MMR root.
Return the new tree root
'''
n_leaves = root.latest_height - root.earliest_height + 1
n_leaves = root.latest_height - (root.earliest_height - 1)
# if there were an odd number of leaves,
# simply replace root with left_child
if n_leaves & 1:
@ -590,7 +590,7 @@ In leaf nodes, some information is repeated. We chose to do this so that leaf no
be treated identically to internal and root nodes for all algorithms and (de)serializers.
Leaf nodes are easily identifiable, as they will show proof of work in the
``hashSubtreeCommitment`` field, and their block range (calculated as
``nLatestHeight - nEarliestHeight + 1``) will be precisely 1. For the same reason, we
``nLatestHeight - (nEarliestHeight - 1)``) will be precisely 1. For the same reason, we
change the semantics of ``hashSubtreeCommitment`` in leaf nodes to commit
Personalized BLAKE2b-256 was selected to match existing Zcash conventions. Adding the