Search in sources :

Example 1 with PendingAttestationSchema

use of tech.pegasys.teku.spec.datastructures.state.PendingAttestation.PendingAttestationSchema in project teku by ConsenSys.

the class BeaconStatePhase0 method applyAdditionalFields.

@Override
protected void applyAdditionalFields(final MutableBeaconState state) {
    state.toMutableVersionPhase0().ifPresent(mutableState -> {
        final PendingAttestationSchema pendingAttestationSchema = mutableState.getBeaconStateSchema().getPendingAttestationSchema();
        mutableState.getPrevious_epoch_attestations().setAll(previous_epoch_attestations.stream().map(pendingAttestation -> pendingAttestation.asInternalPendingAttestation(pendingAttestationSchema)).collect(Collectors.toList()));
        mutableState.getCurrent_epoch_attestations().setAll(current_epoch_attestations.stream().map(pendingAttestation -> pendingAttestation.asInternalPendingAttestation(pendingAttestationSchema)).collect(Collectors.toList()));
    });
}
Also used : PendingAttestationSchema(tech.pegasys.teku.spec.datastructures.state.PendingAttestation.PendingAttestationSchema)

Example 2 with PendingAttestationSchema

use of tech.pegasys.teku.spec.datastructures.state.PendingAttestation.PendingAttestationSchema in project teku by ConsenSys.

the class DataStructureUtil method randomPendingAttestation.

public PendingAttestation randomPendingAttestation() {
    final BeaconStateSchema<?, ?> beaconStateSchema = getBeaconStateSchema();
    checkState(beaconStateSchema instanceof BeaconStateSchemaPhase0, "Pending attestations only exist in phase0");
    final PendingAttestationSchema pendingAttestationSchema = ((BeaconStateSchemaPhase0) beaconStateSchema).getPendingAttestationSchema();
    return randomPendingAttestation(pendingAttestationSchema);
}
Also used : BeaconStateSchemaPhase0(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStateSchemaPhase0) PendingAttestationSchema(tech.pegasys.teku.spec.datastructures.state.PendingAttestation.PendingAttestationSchema)

Example 3 with PendingAttestationSchema

use of tech.pegasys.teku.spec.datastructures.state.PendingAttestation.PendingAttestationSchema in project teku by ConsenSys.

the class BeaconStateSchemaPhase0 method getUniqueFields.

private static List<SszField> getUniqueFields(final SpecConfig specConfig) {
    final PendingAttestationSchema pendingAttestationSchema = new PendingAttestationSchema(specConfig);
    final SszField previousEpochAttestationsField = new SszField(15, BeaconStateFields.PREVIOUS_EPOCH_ATTESTATIONS, () -> SszListSchema.create(pendingAttestationSchema, (long) specConfig.getMaxAttestations() * specConfig.getSlotsPerEpoch()));
    final SszField currentEpochAttestationsField = new SszField(16, BeaconStateFields.CURRENT_EPOCH_ATTESTATIONS, () -> SszListSchema.create(pendingAttestationSchema, (long) specConfig.getMaxAttestations() * specConfig.getSlotsPerEpoch()));
    return List.of(previousEpochAttestationsField, currentEpochAttestationsField);
}
Also used : SszField(tech.pegasys.teku.infrastructure.ssz.sos.SszField) PendingAttestationSchema(tech.pegasys.teku.spec.datastructures.state.PendingAttestation.PendingAttestationSchema)

Aggregations

PendingAttestationSchema (tech.pegasys.teku.spec.datastructures.state.PendingAttestation.PendingAttestationSchema)3 SszField (tech.pegasys.teku.infrastructure.ssz.sos.SszField)1 BeaconStateSchemaPhase0 (tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStateSchemaPhase0)1