Cleanup merkle_root

Add docstring and fix spacing.
This commit is contained in:
Nishant Das 2018-12-28 01:58:24 +08:00 committed by Justin
parent 44d2f44993
commit 8c12896fa0
1 changed files with 6 additions and 3 deletions

View File

@ -955,9 +955,12 @@ def get_beacon_proposer_index(state: BeaconState,
```python
def merkle_root(values):
"""
Merkleize ``values`` (where ``len(values)`` is a power of two) and return the Merkle root.
"""
o = [0] * len(values) + values
for i in range(len(values)-1, 0, -1):
o[i] = hash(o[i*2] + o[i*2+1])
for i in range(len(values) - 1, 0, -1):
o[i] = hash(o[i * 2] + o[i * 2 + 1])
return o[1]
```