Search in sources :

Example 11 with TransactionPo

use of io.nuls.db.entity.TransactionPo 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;
}
Also used : TransferTransaction(io.nuls.ledger.entity.tx.TransferTransaction) AbstractCoinTransaction(io.nuls.ledger.entity.tx.AbstractCoinTransaction) LockNulsTransaction(io.nuls.ledger.entity.tx.LockNulsTransaction) TransactionLocalPo(io.nuls.db.entity.TransactionLocalPo) ArrayList(java.util.ArrayList) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException) TransactionPo(io.nuls.db.entity.TransactionPo)

Example 12 with TransactionPo

use of io.nuls.db.entity.TransactionPo in project nuls by nuls-io.

the class TransactionDaoImpl method getTxs.

@Override
public Page<TransactionPo> getTxs(Long blockHeight, int type, int pageNum, int pageSize) {
    Searchable searchable = new Searchable();
    if (type != 0) {
        searchable.addCondition("type", SearchOperator.eq, type);
    }
    if (blockHeight != null) {
        searchable.addCondition("block_height", SearchOperator.eq, blockHeight);
    }
    long count = getMapper().selectCount(searchable);
    if (count < (pageNum - 1) * pageSize) {
        return new Page<>(pageNum, pageSize);
    }
    PageHelper.orderBy("a.create_time desc");
    if (pageNum > 0 && pageSize > 0) {
        PageHelper.startPage(pageNum, pageSize);
    }
    List<String> txHashList = getMapper().selectTxHashList(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<TransactionPo> poList = getMapper().selectList(searchable);
    Page<TransactionPo> page = new Page<>();
    if (pageSize > 0) {
        page.setPageNumber(pageNum);
        page.setPageSize(pageSize);
    } else {
        page.setPageNumber(1);
        page.setPageSize((int) count);
    }
    page.setTotal(count);
    page.setList(poList);
    return page;
}
Also used : Page(io.nuls.core.dto.Page) TransactionPo(io.nuls.db.entity.TransactionPo) Searchable(io.nuls.db.dao.impl.mybatis.util.Searchable)

Aggregations

TransactionPo (io.nuls.db.entity.TransactionPo)12 AbstractCoinTransaction (io.nuls.ledger.entity.tx.AbstractCoinTransaction)7 LockNulsTransaction (io.nuls.ledger.entity.tx.LockNulsTransaction)7 TransferTransaction (io.nuls.ledger.entity.tx.TransferTransaction)7 ArrayList (java.util.ArrayList)6 NulsRuntimeException (io.nuls.core.exception.NulsRuntimeException)4 NulsException (io.nuls.core.exception.NulsException)3 TransactionLocalPo (io.nuls.db.entity.TransactionLocalPo)3 Page (io.nuls.core.dto.Page)2 Searchable (io.nuls.db.dao.impl.mybatis.util.Searchable)2 DbSession (io.nuls.db.transactional.annotation.DbSession)2 IOException (java.io.IOException)2 Result (io.nuls.core.chain.entity.Result)1 ValidateResult (io.nuls.core.validate.ValidateResult)1 UtxoInputPo (io.nuls.db.entity.UtxoInputPo)1 FileOutputStream (java.io.FileOutputStream)1