Update 0_beacon-chain.md

This commit is contained in:
Justin 2019-01-23 13:52:52 +00:00 committed by GitHub
parent 6f3cb7e7e5
commit dfaf24c75e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -20,7 +20,6 @@
- [Max operations per block](#max-operations-per-block) - [Max operations per block](#max-operations-per-block)
- [Validator registry delta flags](#validator-registry-delta-flags) - [Validator registry delta flags](#validator-registry-delta-flags)
- [Signature domains](#signature-domains) - [Signature domains](#signature-domains)
- [Custody bits](#custody-bits)
- [Data structures](#data-structures) - [Data structures](#data-structures)
- [Beacon chain operations](#beacon-chain-operations) - [Beacon chain operations](#beacon-chain-operations)
- [Proposer slashings](#proposer-slashings) - [Proposer slashings](#proposer-slashings)
@ -1080,6 +1079,9 @@ def get_domain(fork: Fork,
```python ```python
def get_bitfield_bit(bitfield: bytes, i: int) -> int: def get_bitfield_bit(bitfield: bytes, i: int) -> int:
"""
Extract the bit in ``bitfield`` at position ``i``.
"""
return (bitfield[i // 8] >> (7 - (i % 8))) % 2 return (bitfield[i // 8] >> (7 - (i % 8))) % 2
``` ```
@ -1087,12 +1089,13 @@ def get_bitfield_bit(bitfield: bytes, i: int) -> int:
```python ```python
def verify_bitfield(bitfield: bytes, size: int) -> bool: def verify_bitfield(bitfield: bytes, size: int) -> bool:
``` """
Verify ``bitfield`` against the ``size``. Verify ``bitfield`` against the ``size``.
"""
if len(bitfield) != (size + 7) // 8: if len(bitfield) != (size + 7) // 8:
return False return False
for i in range(size + 1, size + size % 8 + 8): for i in range(size + 1, size - size % 8 + 8):
if get_bitfield_bit(bitfield, i) != 0: if get_bitfield_bit(bitfield, i) != 0:
return False return False
@ -1103,6 +1106,9 @@ def verify_bitfield(bitfield: bytes, size: int) -> bool:
```python ```python
def verify_slashable_vote_data(state: BeaconState, slashable_vote_data: SlashableVoteData) -> bool: def verify_slashable_vote_data(state: BeaconState, slashable_vote_data: SlashableVoteData) -> bool:
"""
Verify validity of ``slashable_vote_data`` fields.
"""
if slashable_vote_data.custody_bitfield != 0: # [TO BE REMOVED IN PHASE 1] if slashable_vote_data.custody_bitfield != 0: # [TO BE REMOVED IN PHASE 1]
return False return False