mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-14 12:46:06 +00:00
Use bitwise xor to simplify merkle branch getter
This commit is contained in:
parent
994a42e6b1
commit
78fcda7ce0
@ -698,10 +698,7 @@ def get_merkle_branch(index: uint256) -> bytes32[32]: # size is DEPOSIT_CONTRACT
|
|||||||
idx: uint256 = index + TWO_TO_POWER_OF_TREE_DEPTH
|
idx: uint256 = index + TWO_TO_POWER_OF_TREE_DEPTH
|
||||||
ret: bytes32[32] # size is DEPOSIT_CONTRACT_TREE_DEPTH
|
ret: bytes32[32] # size is DEPOSIT_CONTRACT_TREE_DEPTH
|
||||||
for i in range(DEPOSIT_CONTRACT_TREE_DEPTH):
|
for i in range(DEPOSIT_CONTRACT_TREE_DEPTH):
|
||||||
if idx % 2 == 1:
|
ret[i] = self.deposit_tree[bitwise_xor(idx,1)]
|
||||||
ret[i] = self.deposit_tree[idx - 1]
|
|
||||||
else:
|
|
||||||
ret[i] = self.deposit_tree[idx + 1]
|
|
||||||
idx /= 2
|
idx /= 2
|
||||||
return ret
|
return ret
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user