use of io.nuls.ledger.entity.Balance in project nuls by nuls-io.
the class UtxoLedgerServiceImpl method getBalance.
@Override
public Balance getBalance(String address) {
if (StringUtils.isNotBlank(address)) {
Balance balance = ledgerCacheService.getBalance(address);
return balance;
} else {
Balance allBalance = new Balance();
long usable = 0;
long locked = 0;
for (String addr : NulsContext.LOCAL_ADDRESS_LIST) {
Balance balance = ledgerCacheService.getBalance(addr);
if (null != balance) {
usable += balance.getUsable().getValue();
locked += balance.getLocked().getValue();
}
}
allBalance.setUsable(Na.valueOf(usable));
allBalance.setLocked(Na.valueOf(locked));
allBalance.setBalance(Na.valueOf(usable + locked));
return allBalance;
}
}
Aggregations