use of tech.pegasys.teku.api.response.v1.beacon.StateSyncCommittees in project teku by ConsenSys.
the class ChainDataProvider method getSyncCommitteesFromState.
private StateSyncCommittees getSyncCommitteesFromState(final tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState state, final Optional<UInt64> epochQueryParam) {
final UInt64 epoch = epochQueryParam.orElse(spec.computeEpochAtSlot(state.getSlot()));
final UInt64 slot = spec.computeStartSlotAtEpoch(epoch);
final Optional<SyncCommittee> maybeCommittee = spec.getSyncCommitteeUtil(slot).map(util -> util.getSyncCommittee(state, epoch));
// returned
if (maybeCommittee.isEmpty()) {
return new StateSyncCommittees(List.of(), List.of());
}
final SyncCommittee committee = maybeCommittee.get();
final List<UInt64> committeeIndices = committee.getPubkeys().stream().flatMap(pubkey -> spec.getValidatorIndex(state, pubkey.getBLSPublicKey()).stream()).map(UInt64::valueOf).collect(toList());
return new StateSyncCommittees(committeeIndices, Lists.partition(committeeIndices, spec.atEpoch(epoch).getConfig().getTargetCommitteeSize()));
}
Aggregations