Skip to content

Commit

Permalink
refactor slot filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdi-aouadi committed Jul 16, 2024
1 parent 1d84f37 commit 2c6637a
Showing 1 changed file with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ public synchronized SszList<Attestation> getAttestationsForBlock(
public synchronized List<Attestation> getAttestations(
final Optional<UInt64> maybeSlot, final Optional<UInt64> maybeCommitteeIndex) {

final Predicate<Map.Entry<UInt64, Set<Bytes>>> filterForSlot = getSlotFilter(maybeSlot);
final Predicate<Map.Entry<UInt64, Set<Bytes>>> filterForSlot =
(entry) -> maybeSlot.map(slot -> entry.getKey().equals(slot)).orElse(true);

final Predicate<MatchingDataAttestationGroup> filterForCommitteeIndex =
(group) ->
Expand Down Expand Up @@ -312,18 +313,6 @@ private SchemaDefinitions getSchemaDefinitions(final Optional<UInt64> maybeSlot)
}
}

private Predicate<Map.Entry<UInt64, Set<Bytes>>> getSlotFilter(final Optional<UInt64> maybeSlot) {
if (maybeSlot.isPresent()) {
return (entry) -> entry.getKey().equals(maybeSlot.get());
} else {
return (entry) ->
recentChainData
.getCurrentSlot()
.map(currentSlot -> entry.getKey().equals(currentSlot))
.orElse(true);
}
}

private boolean isValid(
final BeaconState stateAtBlockSlot, final AttestationData attestationData) {
return spec.validateAttestation(stateAtBlockSlot, attestationData).isEmpty();
Expand Down

0 comments on commit 2c6637a

Please sign in to comment.