From 8c12896fa0ef6fcda9ea579cff61a3a7a037f853 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Fri, 28 Dec 2018 01:58:24 +0800 Subject: [PATCH] Cleanup merkle_root Add docstring and fix spacing. --- specs/core/0_beacon-chain.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 50eb0d2a9..309499db9 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -954,10 +954,13 @@ def get_beacon_proposer_index(state: BeaconState, #### `merkle_root` ```python -def merkle_root(values): +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] ```