simplify get_winning_root logic

This commit is contained in:
Danny Ryan 2019-04-03 10:13:05 +11:00
parent 529cf4223e
commit d8df789a70
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
1 changed files with 3 additions and 4 deletions

View File

@ -1761,13 +1761,12 @@ def get_previous_epoch_matching_head_attestations(state: BeaconState) -> List[Pe
```python
def get_winning_root_and_participants(state: BeaconState, slot: Slot, shard: Shard) -> Tuple[Bytes32, List[ValidatorIndex]]:
all_attestations = state.current_epoch_attestations + state.previous_epoch_attestations
attestations = state.current_epoch_attestations if slot_to_epoch(slot) == get_current_epoch(state) else state.previous_epoch_attestations
crosslinks = state.current_crosslinks if slot_to_epoch(slot) == get_current_epoch(state) else state.previous_crosslinks
valid_attestations = [
a for a in all_attestations
if a.data.previous_crosslink == crosslinks[shard] and
a.data.shard == shard and a.data.slot == slot
a for a in attestations
if a.data.previous_crosslink == crosslinks[shard] and a.data.shard == shard
]
all_roots = [a.data.crosslink_data_root for a in valid_attestations]