Small fixes

* pick out committee when getting proposer
* avoid unsigned underflow when chain is starting (since we're using
uint)
This commit is contained in:
Jacek Sieka 2018-11-23 12:57:17 -06:00
parent f513e2022e
commit 70b181fe32
No known key found for this signature in database
GPG Key ID: 6299FEB3EB6FA465
1 changed files with 2 additions and 2 deletions

View File

@ -515,7 +515,7 @@ The following is a function that determines the proposer of a beacon block:
```python ```python
def get_beacon_proposer(state:BeaconState, slot: int) -> ValidatorRecord: def get_beacon_proposer(state:BeaconState, slot: int) -> ValidatorRecord:
first_committee = get_shards_and_committees_for_slot(state, slot)[0] first_committee = get_shards_and_committees_for_slot(state, slot)[0].committee
index = first_committee[slot % len(first_committee)] index = first_committee[slot % len(first_committee)]
return state.validators[index] return state.validators[index]
``` ```
@ -686,7 +686,7 @@ First, a helper function:
```python ```python
def min_empty_validator(validators: List[ValidatorRecord], current_slot: int): def min_empty_validator(validators: List[ValidatorRecord], current_slot: int):
for i, v in enumerate(validators): for i, v in enumerate(validators):
if v.status == WITHDRAWN and v.exit_slot <= current_slot - DELETION_PERIOD: if v.status == WITHDRAWN and v.exit_slot + DELETION_PERIOD <= current_slot:
return i return i
return None return None
``` ```