Search in sources :

Example 1 with ValidatorSystemMetadata

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");
    }
}
Also used : ValidatorSystemMetadata(com.radixdlt.application.validators.state.ValidatorSystemMetadata) DeserializeException(com.radixdlt.serialization.DeserializeException) CandidateForkVote(com.radixdlt.statecomputer.forks.CandidateForkVote) PostProcessorException(com.radixdlt.engine.PostProcessorException)

Example 2 with 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();
}
Also used : ValidatorSystemMetadata(com.radixdlt.application.validators.state.ValidatorSystemMetadata)

Example 3 with ValidatorSystemMetadata

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();
}
Also used : ValidatorSystemMetadata(com.radixdlt.application.validators.state.ValidatorSystemMetadata)

Example 4 with ValidatorSystemMetadata

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();
}
Also used : ValidatorSystemMetadata(com.radixdlt.application.validators.state.ValidatorSystemMetadata)

Aggregations

ValidatorSystemMetadata (com.radixdlt.application.validators.state.ValidatorSystemMetadata)4 PostProcessorException (com.radixdlt.engine.PostProcessorException)1 DeserializeException (com.radixdlt.serialization.DeserializeException)1 CandidateForkVote (com.radixdlt.statecomputer.forks.CandidateForkVote)1