|
15 | 15 |
|
16 | 16 | import static tech.pegasys.teku.ethereum.json.types.EthereumTypes.PUBLIC_KEY_TYPE;
|
17 | 17 | import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.INTEGER_TYPE;
|
| 18 | +import static tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition.listOf; |
18 | 19 |
|
19 | 20 | import it.unimi.dsi.fastutil.ints.IntArrayList;
|
| 21 | +import it.unimi.dsi.fastutil.ints.IntArraySet; |
20 | 22 | import it.unimi.dsi.fastutil.ints.IntSet;
|
21 | 23 | import tech.pegasys.teku.bls.BLSPublicKey;
|
22 |
| -import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition; |
| 24 | +import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition; |
23 | 25 |
|
24 | 26 | public class SyncCommitteeDutyBuilder {
|
25 |
| - public static final SerializableTypeDefinition<SyncCommitteeDuty> SYNC_COMMITTEE_DUTY_TYPE = |
26 |
| - SerializableTypeDefinition.object(SyncCommitteeDuty.class) |
27 |
| - .withField("pubkey", PUBLIC_KEY_TYPE, SyncCommitteeDuty::getPublicKey) |
28 |
| - .withField("validator_index", INTEGER_TYPE, SyncCommitteeDuty::getValidatorIndex) |
| 27 | + public static final DeserializableTypeDefinition<SyncCommitteeDuty> SYNC_COMMITTEE_DUTY_TYPE = |
| 28 | + DeserializableTypeDefinition.object(SyncCommitteeDuty.class, SyncCommitteeDutyBuilder.class) |
| 29 | + .initializer(SyncCommitteeDutyBuilder::new) |
| 30 | + .finisher(SyncCommitteeDutyBuilder::build) |
| 31 | + .withField( |
| 32 | + "pubkey", |
| 33 | + PUBLIC_KEY_TYPE, |
| 34 | + SyncCommitteeDuty::getPublicKey, |
| 35 | + SyncCommitteeDutyBuilder::publicKey) |
| 36 | + .withField( |
| 37 | + "validator_index", |
| 38 | + INTEGER_TYPE, |
| 39 | + SyncCommitteeDuty::getValidatorIndex, |
| 40 | + SyncCommitteeDutyBuilder::validatorIndex) |
29 | 41 | .withField(
|
30 | 42 | "validator_sync_committee_indices",
|
31 |
| - SerializableTypeDefinition.listOf(INTEGER_TYPE), |
| 43 | + listOf(INTEGER_TYPE), |
32 | 44 | syncCommitteeDuty ->
|
33 |
| - new IntArrayList(syncCommitteeDuty.getValidatorSyncCommitteeIndices())) |
| 45 | + new IntArrayList(syncCommitteeDuty.getValidatorSyncCommitteeIndices()), |
| 46 | + (syncCommitteeDutyBuilder, integers) -> |
| 47 | + syncCommitteeDutyBuilder.validatorSyncCommitteeIndices(new IntArraySet(integers))) |
34 | 48 | .build();
|
35 | 49 |
|
36 | 50 | private BLSPublicKey publicKey;
|
|
0 commit comments