use of com.radixdlt.application.validators.state.ValidatorSystemMetadata in project radixdlt by radixdlt.
the class CandidateForkVotesPostProcessor method extractBftNodeAndVoteIfPresent.
private Optional<Pair<BFTNode, CandidateForkVote>> extractBftNodeAndVoteIfPresent(RawSubstateBytes rawSubstateBytes) {
try {
final var validatorSystemMetadataSubstate = (ValidatorSystemMetadata) substateDeserialization.deserialize(rawSubstateBytes.getData());
if (Bytes.isAllZeros(validatorSystemMetadataSubstate.data())) {
return Optional.empty();
}
final var candidateForkVote = new CandidateForkVote(HashCode.fromBytes(validatorSystemMetadataSubstate.data()));
return Optional.of(Pair.of(BFTNode.create(validatorSystemMetadataSubstate.validatorKey()), candidateForkVote));
} catch (DeserializeException e) {
throw new PostProcessorException("Error deserializing ValidatorSystemMetadata");
}
}
use of com.radixdlt.application.validators.state.ValidatorSystemMetadata in project radixdlt by radixdlt.
the class UpdateValidatorSystemMetadataConstructor method construct.
@Override
public void construct(UpdateValidatorSystemMetadata action, TxBuilder builder) throws TxBuilderException {
builder.down(ValidatorSystemMetadata.class, action.validatorKey());
builder.up(new ValidatorSystemMetadata(action.validatorKey(), action.bytes()));
builder.end();
}
use of com.radixdlt.application.validators.state.ValidatorSystemMetadata in project radixdlt by radixdlt.
the class VoteHandler method buildVote.
private void buildVote(TxBuilder builder) {
builder.down(ValidatorSystemMetadata.class, validatorKey);
builder.up(new ValidatorSystemMetadata(validatorKey, forks.getCandidateFork().map(candidateFork -> CandidateForkVote.create(validatorKey, candidateFork).payload()).orElseGet(HashUtils::zero256).asBytes()));
builder.end();
}
use of com.radixdlt.application.validators.state.ValidatorSystemMetadata in project radixdlt by radixdlt.
the class WithdrawVoteHandler method buildWithdrawVote.
private void buildWithdrawVote(TxBuilder builder) {
builder.down(ValidatorSystemMetadata.class, validatorKey);
builder.up(new ValidatorSystemMetadata(validatorKey, HashUtils.zero256().asBytes()));
builder.end();
}
Aggregations