use of com.radixdlt.application.system.state.ValidatorBFTData in project radixdlt by radixdlt.
the class RoundUpdateConstraintScrypt method main.
@Override
public void main(Loader os) {
os.substate(new SubstateDefinition<>(ValidatorBFTData.class, SubstateTypeId.VALIDATOR_BFT_DATA.id(), buf -> {
REFieldSerialization.deserializeReservedByte(buf);
var key = REFieldSerialization.deserializeKey(buf);
var proposalsCompleted = REFieldSerialization.deserializeNonNegativeLong(buf);
var proposalsMissed = REFieldSerialization.deserializeNonNegativeLong(buf);
return new ValidatorBFTData(key, proposalsCompleted, proposalsMissed);
}, (s, buf) -> {
REFieldSerialization.serializeReservedByte(buf);
REFieldSerialization.serializeKey(buf, s.validatorKey());
buf.putLong(s.completedProposals());
buf.putLong(s.missedProposals());
}, (k, buf) -> REFieldSerialization.serializeKey(buf, (ECPublicKey) k)));
os.procedure(new DownProcedure<>(VoidReducerState.class, RoundData.class, d -> new Authorization(PermissionLevel.SUPER_USER, (r, c) -> {
}), (d, s, r, c) -> ReducerResult.incomplete(new EndPrevRound(d))));
os.procedure(new DownProcedure<>(EndPrevRound.class, ValidatorBFTData.class, d -> new Authorization(PermissionLevel.SUPER_USER, (r, c) -> {
}), (d, s, r, c) -> {
var closedRound = s.getClosedRound().view();
var next = new StartValidatorBFTUpdate(closedRound);
next.beginUpdate(d);
return ReducerResult.incomplete(next);
}));
os.procedure(new DownProcedure<>(StartValidatorBFTUpdate.class, ValidatorBFTData.class, d -> new Authorization(PermissionLevel.SUPER_USER, (r, c) -> {
}), (d, s, r, c) -> ReducerResult.incomplete(s.beginUpdate(d))));
os.procedure(new UpProcedure<>(StartValidatorBFTUpdate.class, ValidatorBFTData.class, u -> new Authorization(PermissionLevel.SUPER_USER, (r, c) -> {
}), (s, u, c, r) -> {
var next = s.exit();
return ReducerResult.incomplete(next.update(u, c));
}));
os.procedure(new UpProcedure<>(UpdatingValidatorBFTData.class, ValidatorBFTData.class, u -> new Authorization(PermissionLevel.SUPER_USER, (r, c) -> {
}), (s, u, c, r) -> ReducerResult.incomplete(s.update(u, c))));
os.procedure(new UpProcedure<>(StartNextRound.class, RoundData.class, u -> new Authorization(PermissionLevel.SUPER_USER, (r, c) -> {
}), (s, u, c, r) -> {
s.update(u);
return ReducerResult.complete();
}));
}
Aggregations