Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
lvs007 committed Jul 22, 2020
1 parent f884b53 commit 0fde1b9
Show file tree
Hide file tree
Showing 201 changed files with 1,477 additions and 1,811 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ public AbstractActuator setForkUtils(ForkController forkController) {
this.forkController = forkController;
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ public boolean execute(Object result) throws ContractExeException {

ret.setAssetIssueID(Long.toString(tokenIdNum));
ret.setStatus(fee, code.SUCESS);
}
catch (InvalidProtocolBufferException | BalanceInsufficientException | ArithmeticException e){
} catch (InvalidProtocolBufferException | BalanceInsufficientException | ArithmeticException e) {
logger.debug(e.getMessage(), e);
ret.setStatus(fee, code.FAILED);
throw new ContractExeException(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Arrays;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.tron.common.utils.Commons;
import org.tron.common.utils.DecodeUtil;
import org.tron.common.utils.StringUtil;
import org.tron.core.capsule.AccountCapsule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public boolean execute(Object object) throws ContractExeException {

ret.setExchangeId(id);
ret.setStatus(fee, code.SUCESS);
} catch (BalanceInsufficientException| InvalidProtocolBufferException e) {
} catch (BalanceInsufficientException | InvalidProtocolBufferException e) {
logger.debug(e.getMessage(), e);
ret.setStatus(fee, code.FAILED);
throw new ContractExeException(e.getMessage());
Expand Down Expand Up @@ -175,7 +175,8 @@ public boolean validate() throws ContractValidateException {
long secondTokenBalance = contract.getSecondTokenBalance();

if (dynamicStore.getAllowSameTokenName() == 1) {
if (!Arrays.equals(firstTokenID, TRX_SYMBOL_BYTES) && !TransactionUtil.isNumber(firstTokenID)) {
if (!Arrays.equals(firstTokenID, TRX_SYMBOL_BYTES) && !TransactionUtil
.isNumber(firstTokenID)) {
throw new ContractValidateException("first token id is not a valid number");
}
if (!Arrays.equals(secondTokenID, TRX_SYMBOL_BYTES) && !TransactionUtil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ public boolean validate() throws ContractValidateException {
byte[] anotherTokenID;
long anotherTokenQuant;

if (dynamicStore.getAllowSameTokenName() == 1 &&
!Arrays.equals(tokenID, TRX_SYMBOL_BYTES) &&
if (dynamicStore.getAllowSameTokenName() == 1 &&
!Arrays.equals(tokenID, TRX_SYMBOL_BYTES) &&
!TransactionUtil.isNumber(tokenID)) {
throw new ContractValidateException("token id is not a valid number");
}
Expand All @@ -201,7 +201,7 @@ public boolean validate() throws ContractValidateException {
BigInteger bigTokenQuant = new BigInteger(String.valueOf(tokenQuant));
long newTokenBalance;
long newAnotherTokenBalance;

if (Arrays.equals(tokenID, firstTokenID)) {
anotherTokenID = secondTokenID;
anotherTokenQuant = bigSecondTokenBalance.multiply(bigTokenQuant)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ public boolean validate() throws ContractValidateException {
long tokenQuant = contract.getQuant();
long tokenExpected = contract.getExpected();

if (dynamicStore.getAllowSameTokenName() == 1 &&
!Arrays.equals(tokenID, TRX_SYMBOL_BYTES) &&
if (dynamicStore.getAllowSameTokenName() == 1 &&
!Arrays.equals(tokenID, TRX_SYMBOL_BYTES) &&
!TransactionUtil.isNumber(tokenID)) {
throw new ContractValidateException("token id is not a valid number");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ public boolean validate() throws ContractValidateException {

long anotherTokenQuant;

if (dynamicStore.getAllowSameTokenName() == 1 &&
!Arrays.equals(tokenID, TRX_SYMBOL_BYTES) &&
if (dynamicStore.getAllowSameTokenName() == 1 &&
!Arrays.equals(tokenID, TRX_SYMBOL_BYTES) &&
!TransactionUtil.isNumber(tokenID)) {
throw new ContractValidateException("token id is not a valid number");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.tron.core.store.DelegatedResourceAccountIndexStore;
import org.tron.core.store.DelegatedResourceStore;
import org.tron.core.store.DynamicPropertiesStore;
import org.tron.core.vm.config.VMConfig;
import org.tron.protos.Protocol.AccountType;
import org.tron.protos.Protocol.Transaction.Contract.ContractType;
import org.tron.protos.Protocol.Transaction.Result.code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ public boolean validate() throws ContractValidateException {
}

private void validateValue(Map.Entry<Long, Long> entry) throws ContractValidateException {
ProposalUtil.validator(chainBaseManager.getDynamicPropertiesStore(), forkController, entry.getKey(),
entry.getValue());
ProposalUtil
.validator(chainBaseManager.getDynamicPropertiesStore(), forkController, entry.getKey(),
entry.getValue());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.tron.core.store.DynamicPropertiesStore;
import org.tron.core.store.NullifierStore;
import org.tron.core.store.ZKProofStore;
import org.tron.core.utils.TransactionUtil;
import org.tron.protos.Protocol.AccountType;
import org.tron.protos.Protocol.Transaction.Contract.ContractType;
import org.tron.protos.Protocol.Transaction.Result.code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.tron.common.utils.Commons;
import org.tron.common.utils.DecodeUtil;
import org.tron.common.utils.StringUtil;
import org.tron.core.capsule.AccountCapsule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.tron.core.vm.program.invoke.ProgramInvokeFactoryImpl;
import org.tron.core.vm.repository.Repository;
import org.tron.core.vm.repository.RepositoryImpl;
import org.tron.core.vm.utils.MUtil;
import org.tron.protos.Protocol;
import org.tron.protos.Protocol.Block;
import org.tron.protos.Protocol.Transaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public boolean validate() throws ContractValidateException {

long tronPower = accountCapsule.getTronPower();

sum = LongMath.checkedMultiply(sum, TRX_PRECISION); //trx -> drop. The vote count is based on TRX
sum = LongMath
.checkedMultiply(sum, TRX_PRECISION); //trx -> drop. The vote count is based on TRX
if (sum > tronPower) {
throw new ContractValidateException(
"The total number of votes[" + sum + "] is greater than the tronPower[" + tronPower
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.tron.common.parameter.CommonParameter;
import org.tron.common.utils.Commons;
import org.tron.common.utils.DecodeUtil;
import org.tron.common.utils.StringUtil;
import org.tron.core.capsule.AccountCapsule;
Expand Down Expand Up @@ -115,7 +114,7 @@ public boolean validate() throws ContractValidateException {

boolean isGP = CommonParameter.getInstance()
.getGenesisBlock().getWitnesses().stream().anyMatch(witness ->
Arrays.equals(ownerAddress, witness.getAddress()));
Arrays.equals(ownerAddress, witness.getAddress()));
if (isGP) {
throw new ContractValidateException(
ACCOUNT_EXCEPTION_STR + readableOwnerAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
import org.tron.common.logsfilter.trigger.ContractTrigger;
import org.tron.common.runtime.vm.LogInfo;
import org.tron.common.utils.StringUtil;
import org.tron.common.utils.WalletUtil;
import org.tron.core.capsule.ContractCapsule;
import org.tron.core.db.TransactionTrace;
import org.tron.core.vm.repository.Repository;
import org.tron.core.vm.utils.MUtil;
import org.tron.protos.contract.SmartContractOuterClass.SmartContract.ABI;

@Slf4j
Expand Down Expand Up @@ -78,7 +76,8 @@ public List<ContractTrigger> parseLogInfos(List<LogInfo> logInfos, Repository de
}
ABI abi = contract.getInstance().getAbi();
String creatorAddr = StringUtil.encode58Check(
TransactionTrace.convertToTronAddress(contract.getInstance().getOriginAddress().toByteArray()));
TransactionTrace
.convertToTronAddress(contract.getInstance().getOriginAddress().toByteArray()));
addrMap.put(strContractAddr, creatorAddr);
abiMap.put(strContractAddr, abi);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static org.tron.common.utils.ByteUtil.parseWord;
import static org.tron.common.utils.ByteUtil.stripLeadingZeroes;
import static org.tron.core.db.TransactionTrace.convertToTronAddress;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -72,7 +73,6 @@
import org.tron.core.vm.program.Program;
import org.tron.core.vm.repository.Repository;
import org.tron.protos.Protocol.Permission;
import org.tron.common.crypto.SignatureInterface;

/**
* @author Roman Mandeleil
Expand Down Expand Up @@ -1248,7 +1248,7 @@ public Pair<Boolean, byte[]> execute(byte[] data) {
signHash, spendCvs, spendCount * 32, receiveCvs, receiveCount * 32));
futures.add(futureCheckBindingSig);

boolean withNoTimeout = countDownLatch.await(getCPUTimeLeftInNanoSecond(),
boolean withNoTimeout = countDownLatch.await(getCPUTimeLeftInNanoSecond(),
TimeUnit.NANOSECONDS);
boolean checkResult = true;
for (Future<Boolean> future : futures) {
Expand Down
6 changes: 3 additions & 3 deletions actuator/src/main/java/org/tron/core/vm/VM.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.tron.core.vm;

import static org.tron.common.utils.ByteUtil.EMPTY_BYTE_ARRAY;
import static org.tron.common.crypto.Hash.sha3;
import static org.tron.common.utils.ByteUtil.EMPTY_BYTE_ARRAY;
import static org.tron.core.db.TransactionTrace.convertToTronAddress;
import static org.tron.core.vm.OpCode.CALL;
import static org.tron.core.vm.OpCode.CALLTOKEN;
Expand Down Expand Up @@ -59,7 +59,7 @@ public VM(VMConfig config) {
* + size, unless size is 0, in which case the result is also 0.
*
* @param offset starting position of the memory
* @param size number of bytes needed
* @param size number of bytes needed
* @return offset + size, unless size is 0. In that case memNeeded is also 0.
*/
private static BigInteger memNeeded(DataWord offset, DataWord size) {
Expand Down Expand Up @@ -237,7 +237,7 @@ public void step(Program program) {
//check to see if account does not exist and is not a precompiled contract
if ((op == CALL || op == CALLTOKEN)
&& isDeadAccount(program, callAddressWord)
&& !value.isZero()){
&& !value.isZero()) {
energyCost += energyCosts.getNEW_ACCT_CALL();
}

Expand Down
4 changes: 1 addition & 3 deletions actuator/src/main/java/org/tron/core/vm/VMUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import java.util.Map;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterOutputStream;
import lombok.extern.slf4j.Slf4j;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.ByteUtil;
Expand Down Expand Up @@ -77,7 +75,7 @@ private static File createProgramTraceFile(String txHash) {
} else {
try {
file.getParentFile().mkdirs();
if (!file.createNewFile()){
if (!file.createNewFile()) {
logger.error("failed to create file {}", file.getPath());
}
result = file;
Expand Down
Loading

0 comments on commit 0fde1b9

Please sign in to comment.