use of com.radixdlt.application.tokens.state.ExitingStake in project radixdlt by radixdlt.
the class EpochUpdateConstraintScrypt method main.
@Override
public void main(Loader os) {
os.substate(new SubstateDefinition<>(ValidatorStakeData.class, SubstateTypeId.VALIDATOR_STAKE_DATA.id(), buf -> {
REFieldSerialization.deserializeReservedByte(buf);
var isRegistered = REFieldSerialization.deserializeBoolean(buf);
var amount = REFieldSerialization.deserializeUInt256(buf);
var delegate = REFieldSerialization.deserializeKey(buf);
var ownership = REFieldSerialization.deserializeUInt256(buf);
var rakePercentage = REFieldSerialization.deserializeInt(buf);
var ownerAddress = REFieldSerialization.deserializeAccountREAddr(buf);
return ValidatorStakeData.create(delegate, amount, ownership, rakePercentage, ownerAddress, isRegistered);
}, (s, buf) -> {
REFieldSerialization.serializeReservedByte(buf);
REFieldSerialization.serializeBoolean(buf, s.isRegistered());
buf.put(s.amount().toByteArray());
REFieldSerialization.serializeKey(buf, s.validatorKey());
buf.put(s.totalOwnership().toByteArray());
buf.putInt(s.rakePercentage());
REFieldSerialization.serializeREAddr(buf, s.ownerAddr());
}, buf -> REFieldSerialization.deserializeKey(buf), (k, buf) -> REFieldSerialization.serializeKey(buf, (ECPublicKey) k), k -> ValidatorStakeData.createVirtual((ECPublicKey) k)));
os.substate(new SubstateDefinition<>(StakeOwnership.class, SubstateTypeId.STAKE_OWNERSHIP.id(), buf -> {
REFieldSerialization.deserializeReservedByte(buf);
var delegate = REFieldSerialization.deserializeKey(buf);
var owner = REFieldSerialization.deserializeAccountREAddr(buf);
var amount = REFieldSerialization.deserializeNonZeroUInt256(buf);
return new StakeOwnership(delegate, owner, amount);
}, (s, buf) -> {
REFieldSerialization.serializeReservedByte(buf);
REFieldSerialization.serializeKey(buf, s.delegateKey());
REFieldSerialization.serializeREAddr(buf, s.owner());
buf.put(s.amount().toByteArray());
}));
os.substate(new SubstateDefinition<>(ExitingStake.class, SubstateTypeId.EXITING_STAKE.id(), buf -> {
REFieldSerialization.deserializeReservedByte(buf);
var epochUnlocked = REFieldSerialization.deserializeNonNegativeLong(buf);
var delegate = REFieldSerialization.deserializeKey(buf);
var owner = REFieldSerialization.deserializeAccountREAddr(buf);
var amount = REFieldSerialization.deserializeNonZeroUInt256(buf);
return new ExitingStake(epochUnlocked, delegate, owner, amount);
}, (s, buf) -> {
REFieldSerialization.serializeReservedByte(buf);
buf.putLong(s.epochUnlocked());
REFieldSerialization.serializeKey(buf, s.delegateKey());
REFieldSerialization.serializeREAddr(buf, s.owner());
buf.put(s.amount().toByteArray());
}));
registerGenesisTransitions(os);
// Epoch update
epochUpdate(os);
}
Aggregations