use of io.nuls.db.entity.TransactionPo in project nuls by nuls-io.
the class UtxoTransferTool method toTransactionPojo.
public static TransactionPo toTransactionPojo(Transaction tx) throws IOException {
TransactionPo po = new TransactionPo();
if (tx.getHash() != null) {
po.setHash(tx.getHash().getDigestHex());
}
po.setType(tx.getType());
po.setCreateTime(tx.getTime());
po.setBlockHeight(tx.getBlockHeight());
po.setTxIndex(tx.getIndex());
po.setSize(tx.getSize());
po.setScriptSig(tx.getScriptSig());
if (null != tx.getTxData()) {
po.setTxData(tx.getTxData().serialize());
}
if (null != tx.getRemark()) {
po.setRemark(new String(tx.getRemark(), NulsContext.DEFAULT_ENCODING));
}
if (null != tx.getFee()) {
po.setFee(tx.getFee().getValue());
}
return po;
}
use of io.nuls.db.entity.TransactionPo in project nuls by nuls-io.
the class UtxoLedgerServiceImpl method getTxList.
@Override
public Page<Transaction> getTxList(Long height, int type, int pageNum, int pageSize) throws Exception {
Page<TransactionPo> poPage = txDao.getTxs(height, type, pageNum, pageSize);
Page<Transaction> txPage = new Page<>(poPage);
List<Transaction> txList = new ArrayList<>();
for (TransactionPo po : poPage.getList()) {
txList.add(UtxoTransferTool.toTransaction(po));
}
txPage.setList(txList);
return txPage;
}
use of io.nuls.db.entity.TransactionPo in project nuls by nuls-io.
the class UtxoLedgerServiceImpl method getTxList.
@Override
public List<Transaction> getTxList(Long blockHeight, String address, int txType, int pageNumber, int pageSize) throws Exception {
List<Transaction> txList = null;
if (StringUtils.isNotBlank(address) && NulsContext.LOCAL_ADDRESS_LIST.contains(address)) {
txList = getLocalTxList(blockHeight, address, txType, pageNumber, pageSize);
} else {
txList = new ArrayList<>();
List<Transaction> cacheTxList = getCacheTxList(address, txType);
txList.addAll(cacheTxList);
List<TransactionPo> poList;
if (pageNumber == 0 && pageSize == 0) {
poList = txDao.getTxs(blockHeight, address, txType, 0, 0);
for (TransactionPo 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.getTxs(blockHeight, address, txType, start, pageSize);
for (TransactionPo po : poList) {
txList.add(UtxoTransferTool.toTransaction(po));
}
}
return txList;
}
use of io.nuls.db.entity.TransactionPo in project nuls by nuls-io.
the class UtxoLedgerServiceImpl method getTxList.
@Override
public List<Transaction> getTxList(String blockHash) throws Exception {
List<Transaction> txList = new ArrayList<>();
List<TransactionPo> poList = txDao.getTxs(blockHash);
for (TransactionPo po : poList) {
txList.add(UtxoTransferTool.toTransaction(po));
}
return txList;
}
use of io.nuls.db.entity.TransactionPo in project nuls by nuls-io.
the class UtxoLedgerServiceImpl method getTx.
@Override
public Transaction getTx(NulsDigestData hash) {
Transaction tx = getTxFromCache(hash);
if (tx != null) {
return tx;
}
TransactionPo po = txDao.gettx(hash.getDigestHex());
if (null == po) {
return null;
}
try {
return UtxoTransferTool.toTransaction(po);
} catch (Exception e) {
Log.error(e);
}
return null;
}
Aggregations