Merge pull request #414 from benjaminion/vyper-merkle-branch

Add getter to Vyper contract for Merkle branches
This commit is contained in:
Hsiao-Wei Wang 2019-01-14 14:49:40 +08:00 committed by GitHub
commit 43d0142da9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -689,6 +689,15 @@ def deposit(deposit_input: bytes[2048]):
def get_deposit_root() -> bytes32: def get_deposit_root() -> bytes32:
return self.deposit_tree[1] return self.deposit_tree[1]
@public
@constant
def get_branch(leaf: uint256) -> bytes32[32]: # size is DEPOSIT_CONTRACT_TREE_DEPTH (symbolic const not supported)
branch: bytes32[32] # size is DEPOSIT_CONTRACT_TREE_DEPTH
index: uint256 = leaf + TWO_TO_POWER_OF_TREE_DEPTH
for i in range(DEPOSIT_CONTRACT_TREE_DEPTH):
branch[i] = self.deposit_tree[bitwise_xor(index, 1)]
index /= 2
return branch
``` ```
## Beacon chain processing ## Beacon chain processing