update utxo account codes
@@ -37,7 +37,6 @@ import io.nuls.kernel.model.Coin;
import io.nuls.kernel.model.NulsDigestData;
import io.nuls.kernel.model.Transaction;
import io.nuls.kernel.utils.AddressTool;
-import io.nuls.utxo.accounts.constant.UtxoAccountsConstant;
import io.nuls.utxo.accounts.service.UtxoAccountsService;
import io.nuls.utxo.accounts.storage.constant.UtxoAccountsStorageConstant;
import io.nuls.utxo.accounts.storage.po.LocalCacheBlockBalance;
@@ -56,20 +55,6 @@ public class UtxoAccountsServiceImpl implements UtxoAccountsService {
@Autowired
ContractService contractService;
- private boolean isPermanentLocked(int txType) {
- if (txType == UtxoAccountsConstant.TX_TYPE_REGISTER_AGENT || txType == UtxoAccountsConstant.TX_TYPE_JOIN_CONSENSUS) {
- return true;
- }
- return false;
- }
-
- private boolean isPermanentUnLocked(int txType) {
- if (txType == UtxoAccountsConstant.TX_TYPE_CANCEL_DEPOSIT || txType == UtxoAccountsConstant.TX_TYPE_STOP_AGENT || txType == UtxoAccountsConstant.TX_TYPE_RED_PUNISH) {
- return true;
- }
- return false;
- }
-
private byte[] getInputAddress(Coin from) {
byte[] fromHash;
int fromIndex;
@@ -138,38 +123,28 @@ public class UtxoAccountsServiceImpl implements UtxoAccountsService {
utxoAccountsMap.put(address, balance);
}
if (isInput) {
- if (isPermanentUnLocked(tx.getType())) {
+ if (coin.getLockTime() == -1) {
//remove balance
balance.setUnLockedPermanentBalance(balance.getUnLockedPermanentBalance() + (coin.getNa().getValue()));
}
balance.setInputBalance(balance.getInputBalance() + (coin.getNa().getValue()));
} else {
- if (isPermanentLocked(tx.getType())) {
//add locked balance
if (coin.getLockTime() == -1) {
balance.setLockedPermanentBalance(balance.getLockedPermanentBalance() + (coin.getNa().getValue()));
- }
- } else {
- //add lockedTime output
- if (coin.getLockTime() > 0) {
+ } else
//by time
if (coin.getLockTime() > TimeService.currentTimeMillis()) {
LockedBalance lockedBalance = new LockedBalance();
lockedBalance.setLockedBalance(coin.getNa().getValue());
lockedBalance.setLockedTime(coin.getLockTime());
balance.getLockedTimeList().add(lockedBalance);
- } else {
- //by height
- if (coin.getLockTime() > netBlockHeight) {
+ } else if (coin.getLockTime() > netBlockHeight) {
LockedBalance lockedBalance = new LockedBalance();
lockedBalance.setLockedBalance(coin.getNa().getValue());
lockedBalance.setLockedTime(coin.getLockTime());
balance.getLockedHeightList().add(lockedBalance);
}
- }
-
- }
- }
balance.setOutputBalance(balance.getOutputBalance() + (coin.getNa()).getValue());
}
// balance.setOwner(coin.getOwner());
