Skip to content
This repository was archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
Rework get_aggregatable_attestations
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed Nov 21, 2019
1 parent 7e39a23 commit dd1fee2
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions trinity/protocol/bcc_libp2p/servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,24 +419,18 @@ def get_ready_attestations(
else:
yield attestation

@to_tuple
def get_aggregatable_attestations(
self,
slot: Slot,
committee_index: Optional[CommitteeIndex] = None
) -> Iterable[Attestation]:
for attestation in self.attestation_pool.get_all():
try:
# Filter by committee_index
if committee_index is not None and committee_index != attestation.data.index:
continue
if slot != attestation.data.slot:
continue

except ValidationError:
continue
else:
yield attestation
committee_index: CommitteeIndex
) -> Tuple[Attestation, ...]:
return tuple(
filter(
lambda attestation:
slot == attestation.data.slot and committee_index == attestation.data.index,
self.attestation_pool.get_all()
)
)

def import_attestation(self, attestation: Attestation) -> None:
self.attestation_pool.add(attestation)

0 comments on commit dd1fee2

Please sign in to comment.