use of tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregateSchema in project teku by ConsenSys.
the class BeaconBlockBodyAltair method asInternalBeaconBlockBody.
@Override
public tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody asInternalBeaconBlockBody(final SpecVersion spec, Consumer<BeaconBlockBodyBuilder> builderRef) {
BeaconBlockBodySchemaAltair<?> schema = (BeaconBlockBodySchemaAltair<?>) spec.getSchemaDefinitions().getBeaconBlockBodySchema();
SyncAggregateSchema syncAggregateSchema = schema.getSyncAggregateSchema();
return super.asInternalBeaconBlockBody(spec, (builder) -> {
builderRef.accept(builder);
builder.syncAggregate(() -> syncAggregateSchema.create(syncAggregateSchema.getSyncCommitteeBitsSchema().fromBytes(syncAggregate.syncCommitteeBits).getAllSetBits(), syncAggregate.syncCommitteeSignature.asInternalBLSSignature()));
});
}
use of tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregateSchema in project teku by ConsenSys.
the class SyncCommitteeUtil method createSyncAggregate.
public SyncAggregate createSyncAggregate(final Iterable<SyncCommitteeContribution> contributions) {
final SyncAggregateSchema schema = BeaconBlockBodySchemaAltair.required(schemaDefinitionsAltair.getBeaconBlockBodySchema()).getSyncAggregateSchema();
final IntList participantIndices = new IntArrayList();
final List<BLSSignature> signatures = new ArrayList<>();
for (SyncCommitteeContribution contribution : contributions) {
final int subcommitteeIndex = contribution.getSubcommitteeIndex().intValue();
final int subcommitteeOffset = getSubcommitteeSize() * subcommitteeIndex;
contribution.getAggregationBits().streamAllSetBits().forEach(index -> participantIndices.add(subcommitteeOffset + index));
signatures.add(contribution.getSignature());
}
if (signatures.isEmpty()) {
return schema.createEmpty();
} else {
return schema.create(participantIndices, BLS.aggregate(signatures));
}
}
Aggregations