Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PART 3 - GET/Attestation Pool API - Add API interface #8438

Merged
merged 19 commits into from
Jul 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,11 @@ public Stream<ValidatableAttestation> stream(final Optional<UInt64> committeeInd

public Stream<ValidatableAttestation> stream(
final Optional<UInt64> committeeIndex, final boolean requiresCommitteeBits) {
// Group Attestation type mismatch
if (requiresCommitteeBits != includedValidators.requiresCommitteeBits()) {
if (noMatchingAttestations(committeeIndex, requiresCommitteeBits)) {
return Stream.empty();
} else {
return StreamSupport.stream(spliterator(committeeIndex), false);
mehdi-aouadi marked this conversation as resolved.
Show resolved Hide resolved
}
// Pre electra attestation and committee index not matching
if (committeeIndex.isPresent()
&& !includedValidators.requiresCommitteeBits()
&& !attestationData.getIndex().equals(committeeIndex.get())) {
return Stream.empty();
}
// Filter based on the committee index
return StreamSupport.stream(spliterator(committeeIndex), false);
}

public Spliterator<ValidatableAttestation> spliterator(final Optional<UInt64> committeeIndex) {
Expand Down Expand Up @@ -245,6 +238,18 @@ public boolean matchesCommitteeShufflingSeed(final Set<Bytes32> validSeeds) {
return committeeShufflingSeed.map(validSeeds::contains).orElse(false);
}

private boolean noMatchingAttestations(
Optional<UInt64> committeeIndex, boolean requiresCommitteeBits) {
return requiresCommitteeBits != includedValidators.requiresCommitteeBits()
|| noMatchingPreElectraAttestations(committeeIndex);
}

private boolean noMatchingPreElectraAttestations(Optional<UInt64> committeeIndex) {
return committeeIndex.isPresent()
&& !includedValidators.requiresCommitteeBits()
&& !attestationData.getIndex().equals(committeeIndex.get());
}

private class AggregatingIterator implements Iterator<ValidatableAttestation> {

private final Optional<UInt64> maybeCommitteeIndex;
Expand Down
Loading