Skip to content

Commit

Permalink
suicide withdrawRewardToBalance add judgement of allowTvmStake
Browse files Browse the repository at this point in the history
  • Loading branch information
dpneko committed Aug 24, 2020
1 parent f761696 commit e62fd06
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions actuator/src/main/java/org/tron/core/vm/program/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,9 @@ public void suicide(DataWord obtainerAddress) {
byte[] owner = TransactionTrace.convertToTronAddress(getContractAddress().getLast20Bytes());
byte[] obtainer = TransactionTrace.convertToTronAddress(obtainerAddress.getLast20Bytes());

withdrawRewardToBalance(owner, getContractState());
if (VMConfig.allowTvmStake()) {
withdrawRewardToBalance(owner, getContractState());
}

long balance = getContractState().getBalance(owner);

Expand Down Expand Up @@ -546,17 +548,19 @@ public void suicide(DataWord obtainerAddress) {
throw new BytecodeExecutionException("transfer failure");
}
}
suicideFreezeBalanceAndVote(owner, obtainer, getContractState());
if (VMConfig.allowTvmStake()) {
suicideFreezeBalanceAndVote(owner, obtainer, getContractState());
//delete delegationStore
getResult().addDeleteDelegation(this.getContractAddress());
}
getResult().addDeleteAccount(this.getContractAddress());
//delete delegationStore
getResult().addDeleteDelegation(this.getContractAddress());
}

public Repository getContractState() {
return this.contractState;
}

private void withdrawRewardToBalance(byte[] owner, Repository repository){
private void withdrawRewardToBalance(byte[] owner, Repository repository) {
ContractService contractService = ContractService.getInstance();
contractService.withdrawReward(owner, getContractState());
AccountCapsule accountCapsule = repository.getAccount(owner);
Expand All @@ -575,9 +579,6 @@ private void withdrawRewardToBalance(byte[] owner, Repository repository){
}

private void suicideFreezeBalanceAndVote(byte[] owner, byte[] obtainer, Repository repository) {
if (!VMConfig.allowTvmStake()) {
return;
}
AccountCapsule ownerCapsule = repository.getAccount(owner);
if (ownerCapsule.getFrozenCount() == 0) {
return;
Expand Down

0 comments on commit e62fd06

Please sign in to comment.