Skip to content

Commit

Permalink
don't transaction fee to SR if the transaction is out of time
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-liu55 committed Nov 11, 2020
1 parent 12d2492 commit 8b50e9c
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ public void payEnergyBill(DynamicPropertiesStore dynamicPropertiesStore,

if (Objects.isNull(origin) && dynamicPropertiesStore.getAllowTvmConstantinople() == 1) {
payEnergyBill(dynamicPropertiesStore, accountStore, forkController, caller,
receipt.getEnergyUsageTotal(), energyProcessor, now);
receipt.getEnergyUsageTotal(), receipt.getResult(), energyProcessor, now);
return;
}

if (caller.getAddress().equals(origin.getAddress())) {
payEnergyBill(dynamicPropertiesStore, accountStore, forkController, caller,
receipt.getEnergyUsageTotal(), energyProcessor, now);
receipt.getEnergyUsageTotal(), receipt.getResult(), energyProcessor, now);
} else {
long originUsage = Math.multiplyExact(receipt.getEnergyUsageTotal(), percent) / 100;
originUsage = getOriginUsage(dynamicPropertiesStore, origin, originEnergyLimit,
Expand All @@ -141,7 +141,7 @@ public void payEnergyBill(DynamicPropertiesStore dynamicPropertiesStore,
energyProcessor.useEnergy(origin, originUsage, now);
this.setOriginEnergyUsage(originUsage);
payEnergyBill(dynamicPropertiesStore, accountStore, forkController,
caller, callerUsage, energyProcessor, now);
caller, callerUsage, receipt.getResult(), energyProcessor, now);
}
}

Expand All @@ -161,6 +161,7 @@ private void payEnergyBill(
ForkController forkController,
AccountCapsule account,
long usage,
contractResult contractResult,
EnergyProcessor energyProcessor,
long now) throws BalanceInsufficientException {
long accountEnergyLeft = energyProcessor.getAccountLeftEnergyFromFreeze(account);
Expand Down Expand Up @@ -193,7 +194,8 @@ private void payEnergyBill(
}
account.setBalance(balance - energyFee);

if (dynamicPropertiesStore.supportTransactionFeePool()) {
if (dynamicPropertiesStore.supportTransactionFeePool() &&
!contractResult.equals(contractResult.OUT_OF_TIME)) {
dynamicPropertiesStore
.saveTransactionFeePool(dynamicPropertiesStore.getTransactionFeePool() + energyFee);
} else {
Expand Down

0 comments on commit 8b50e9c

Please sign in to comment.