use of io.nuls.db.entity.TransactionLocalPo in project nuls by nuls-io.
the class UtxoLedgerServiceImpl method getLocalTxList.
public List<Transaction> getLocalTxList(Long blockHeight, String address, int txType, int pageNumber, int pageSize) throws Exception {
List<Transaction> txList = new ArrayList<>();
List<Transaction> cacheTxList = getCacheTxList(address, txType);
txList.addAll(cacheTxList);
List<TransactionLocalPo> poList;
if (pageNumber == 0 && pageSize == 0) {
poList = txDao.getLocalTxs(blockHeight, address, txType, 0, 0);
for (TransactionLocalPo po : poList) {
txList.add(UtxoTransferTool.toTransaction(po));
}
return txList;
}
int start = (pageNumber - 1) * pageSize;
if (txList.size() >= start + pageSize) {
return txList.subList(start, start + pageSize);
} else if (start < txList.size()) {
txList = txList.subList(start, txList.size());
start = 0;
pageSize = pageSize - txList.size();
} else {
start = start - txList.size();
}
poList = txDao.getLocalTxs(blockHeight, address, txType, start, pageSize);
for (TransactionLocalPo po : poList) {
txList.add(UtxoTransferTool.toTransaction(po));
}
return txList;
}
use of io.nuls.db.entity.TransactionLocalPo in project nuls by nuls-io.
the class UtxoLedgerServiceImpl method getTxList.
@Override
public List<Transaction> getTxList(String address, int txType) throws Exception {
if (StringUtils.isBlank(address) && txType == 0) {
throw new NulsRuntimeException(ErrorCode.PARAMETER_ERROR);
}
List<Transaction> txList = new ArrayList<>();
List<Transaction> cacheTxList = getCacheTxList(address, txType);
txList.addAll(cacheTxList);
if (StringUtils.isNotBlank(address) && NulsContext.LOCAL_ADDRESS_LIST.contains(address)) {
List<TransactionLocalPo> poList = txDao.getLocalTxs(null, address, txType, 0, 0);
for (TransactionLocalPo po : poList) {
txList.add(UtxoTransferTool.toTransaction(po));
}
} else {
List<TransactionPo> poList = txDao.getTxs(null, address, txType, 0, 0);
for (TransactionPo po : poList) {
txList.add(UtxoTransferTool.toTransaction(po));
}
}
return txList;
}
use of io.nuls.db.entity.TransactionLocalPo in project nuls by nuls-io.
the class AccountTxDaoImpl method importAccount.
@DbSession
@Override
public void importAccount(List<AccountPo> accountPoList) {
for (AccountPo account : accountPoList) {
accountDao.save(account);
for (int i = 0; i < account.getMyTxs().size(); i++) {
TransactionLocalPo tx = account.getMyTxs().get(i);
txDao.save(tx);
}
}
}
use of io.nuls.db.entity.TransactionLocalPo in project nuls by nuls-io.
the class TransactionLocalDaoImpl method getTxs.
@Override
public List<TransactionLocalPo> getTxs(Long blockHeight, String address, int type, int start, int limit) {
Searchable searchable = new Searchable();
// searchable.addCondition(condition);
if (type != 0) {
searchable.addCondition("a.type", SearchOperator.eq, type);
}
if (blockHeight != null) {
searchable.addCondition("a.block_height", SearchOperator.eq, blockHeight);
}
if (StringUtils.isNotBlank(address)) {
searchable.addCondition("e.address", SearchOperator.eq, address);
}
if (start == 0 & limit == 0) {
PageHelper.orderBy("a.create_time desc, b.in_index asc, c.out_index asc");
return getMapper().selectByAddress(searchable);
}
PageHelper.offsetPage(start, limit);
PageHelper.orderBy("a.create_time desc");
List<String> txHashList = getMapper().selectTxHashListRelation(searchable);
searchable = new Searchable();
searchable.addCondition("a.hash", SearchOperator.in, txHashList);
PageHelper.orderBy("a.create_time desc, b.in_index asc, c.out_index asc");
List<TransactionLocalPo> localPoList = getMapper().selectByAddress(searchable);
return localPoList;
}
Aggregations