use of org.tron.protos.Contract.WitnessUpdateContract in project java-tron by tronprotocol.
the class WitnessUpdateActuator method execute.
@Override
public boolean execute(TransactionResultCapsule ret) throws ContractExeException {
long fee = calcFee();
try {
final WitnessUpdateContract witnessUpdateContract = this.contract.unpack(WitnessUpdateContract.class);
this.updateWitness(witnessUpdateContract);
ret.setStatus(fee, code.SUCESS);
} catch (final InvalidProtocolBufferException e) {
logger.debug(e.getMessage(), e);
ret.setStatus(fee, code.FAILED);
throw new ContractExeException(e.getMessage());
}
return true;
}
use of org.tron.protos.Contract.WitnessUpdateContract in project java-tron by tronprotocol.
the class WitnessUpdateActuator method validate.
@Override
public boolean validate() throws ContractValidateException {
try {
if (!this.contract.is(WitnessUpdateContract.class)) {
throw new ContractValidateException("contract type error,expected type [WitnessUpdateContract],real type[" + this.contract.getClass() + "]");
}
final WitnessUpdateContract contract = this.contract.unpack(WitnessUpdateContract.class);
Preconditions.checkNotNull(contract.getOwnerAddress(), "OwnerAddress is null");
if (this.dbManager.getWitnessStore().get(contract.getOwnerAddress().toByteArray()) == null) {
throw new ContractValidateException("Witness not existed");
}
} catch (final Exception ex) {
ex.printStackTrace();
throw new ContractValidateException(ex.getMessage());
}
return true;
}
Aggregations