mirror of https://github.com/zcash/zips.git
Move bag_peaks() pseudocode into the first block it is used in
This commit is contained in:
parent
be5dd9c66e
commit
1ef1388501
19
zip-0221.rst
19
zip-0221.rst
|
@ -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
|
||||
----------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue