Move bag_peaks() pseudocode into the first block it is used in

This commit is contained in:
Jack Grigg 2020-03-04 08:40:14 +13:00 committed by Daira Hopwood
parent be5dd9c66e
commit 1ef1388501
1 changed files with 10 additions and 9 deletions

View File

@ -471,6 +471,16 @@ With each new block ``B_n``, we append a new MMR leaf node corresponding to bloc
return peaks
def bag_peaks(peaks: List[ZcashMMRNode]) -> ZcashMMRNode:
'''
"Bag" a list of peaks, and return the final root
'''
root = peaks[0]
for i in range(1, len(peaks)):
root = make_parent(root, peaks[i])
return root
def append(root: ZcashMMRNode, leaf: ZcashMMRNode) -> ZcashMMRNode:
'''Append a leaf to an existing tree, return the new tree root'''
# recursively find a list of peaks in the current tree
@ -527,15 +537,6 @@ in the right subtree of the MMR root.
new_root = bag_peaks(peaks)
return new_root
def bag_peaks(peaks: List[ZcashMMRNode]) -> ZcashMMRNode:
'''
"Bag" a list of peaks, and return the final root
'''
root = peaks[0]
for i in range(1, len(peaks)):
root = make_parent(root, peaks[i])
return root
Header modifications specification
----------------------------------