Skip to content

Commit 3a7901d

Browse files
committed
Merge branch 'develop' of https://github.com/tronprotocol/java-tron into develop
2 parents 7b8a6ba + 1c5d483 commit 3a7901d

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

src/main/java/org/tron/core/actuator/TransferActuator.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
@Slf4j
2222
public class TransferActuator extends AbstractActuator {
2323

24-
TransferContract transferContract;
25-
byte[] ownerAddress;
26-
byte[] toAddress;
27-
long amount;
24+
private TransferContract transferContract;
25+
private byte[] ownerAddress;
26+
private byte[] toAddress;
27+
private long amount;
2828

2929
TransferActuator(Any contract, Manager dbManager) {
3030
super(contract, dbManager);
@@ -40,24 +40,20 @@ public class TransferActuator extends AbstractActuator {
4040

4141
@Override
4242
public boolean execute(TransactionResultCapsule ret) throws ContractExeException {
43-
4443
long fee = calcFee();
4544
try {
46-
47-
// if account with to_address is not existed, create it.
45+
// if account with to_address does not exist, create it first.
4846
AccountCapsule toAccount = dbManager.getAccountStore()
4947
.get(transferContract.getToAddress().toByteArray());
5048
if (toAccount == null) {
5149
toAccount = new AccountCapsule(ByteString.copyFrom(toAddress), AccountType.Normal,
5250
dbManager.getHeadBlockTimeStamp());
5351
dbManager.getAccountStore().put(toAddress, toAccount);
5452
}
55-
dbManager.adjustBalance(transferContract.getOwnerAddress().toByteArray(), -calcFee());
53+
dbManager.adjustBalance(transferContract.getOwnerAddress().toByteArray(), -fee);
5654
ret.setStatus(fee, code.SUCESS);
57-
dbManager.adjustBalance(transferContract.getOwnerAddress().toByteArray(),
58-
-amount);
59-
dbManager.adjustBalance(transferContract.getToAddress().toByteArray(),
60-
amount);
55+
dbManager.adjustBalance(transferContract.getOwnerAddress().toByteArray(), -amount);
56+
dbManager.adjustBalance(transferContract.getToAddress().toByteArray(), amount);
6157
} catch (BalanceInsufficientException e) {
6258
logger.debug(e.getMessage(), e);
6359
ret.setStatus(fee, code.FAILED);
@@ -112,7 +108,7 @@ public boolean validate() throws ContractValidateException {
112108
throw new ContractValidateException("balance is not sufficient.");
113109
}
114110

115-
// if account with to_address is not existed, create it.
111+
// if account with to_address is not existed, the minimum amount is 1 TRX
116112
AccountCapsule toAccount = dbManager.getAccountStore()
117113
.get(transferContract.getToAddress().toByteArray());
118114
if (toAccount == null) {
@@ -123,15 +119,14 @@ public boolean validate() throws ContractValidateException {
123119
}
124120
} else {
125121
//check to account balance if overflow
126-
balance = Math.addExact(toAccount.getBalance(), amount);
122+
long toAddressBalance = Math.addExact(toAccount.getBalance(), amount);
127123
}
128124
} catch (Exception ex) {
129125
throw new ContractValidateException(ex.getMessage());
130126
}
131127
return true;
132128
}
133129

134-
135130
@Override
136131
public ByteString getOwnerAddress() throws InvalidProtocolBufferException {
137132
return contract.unpack(TransferContract.class).getOwnerAddress();
@@ -141,4 +136,4 @@ public ByteString getOwnerAddress() throws InvalidProtocolBufferException {
141136
public long calcFee() {
142137
return ChainConstant.TRANSFER_FEE;
143138
}
144-
}
139+
}

src/main/java/org/tron/core/capsule/TransactionResultCapsule.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
@Slf4j
88
public class TransactionResultCapsule implements ProtoCapsule<Transaction.Result> {
9+
910
private Transaction.Result transactionResult;
1011

1112
/**
@@ -19,7 +20,6 @@ public TransactionResultCapsule() {
1920
this.transactionResult = Transaction.Result.newBuilder().build();
2021
}
2122

22-
2323
public TransactionResultCapsule(Transaction.Result.code code, long fee) {
2424
Transaction.Result ret = Transaction.Result.newBuilder().setRet(code).setFee(fee).build();
2525
}
@@ -38,7 +38,6 @@ public void setErrorCode(Transaction.Result.code code) {
3838
this.transactionResult = this.transactionResult.toBuilder().setRet(code).build();
3939
}
4040

41-
4241
@Override
4342
public byte[] getData() {
4443
return this.transactionResult.toByteArray();
@@ -48,4 +47,4 @@ public byte[] getData() {
4847
public Result getInstance() {
4948
return this.transactionResult;
5049
}
51-
}
50+
}

src/main/java/org/tron/core/config/Parameter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public interface Parameter {
44

55
interface ChainConstant {
66

7-
long TRANSFER_FEE = 0; // 1 drop
7+
long TRANSFER_FEE = 0; // free
88
long ASSET_ISSUE_FEE = 1024000000; // 1024 trx 1024*10^6
99
long VOTE_WITNESS_FEE = 10000; // 10000 drop
1010
long CREATE_ACCOUNT_FEE = 10000; // 10000 drop

0 commit comments

Comments
 (0)