use of org.ethereum.db.TransactionInfo in project rskj by rsksmart.
the class Web3Impl method eth_getTransactionByHash.
@Override
public TransactionResultDTO eth_getTransactionByHash(String transactionHash) throws Exception {
TransactionResultDTO s = null;
try {
Keccak256 txHash = new Keccak256(stringHexToByteArray(transactionHash));
Block block = null;
TransactionInfo txInfo = blockchain.getTransactionInfo(txHash.getBytes());
if (txInfo == null) {
List<Transaction> txs = this.getTransactionsByJsonBlockId("pending");
for (Transaction tx : txs) {
if (tx.getHash().equals(txHash)) {
return s = new TransactionResultDTO(null, null, tx);
}
}
} else {
block = blockchain.getBlockByHash(txInfo.getBlockHash());
// need to return txes only from main chain
Block mainBlock = blockchain.getBlockByNumber(block.getNumber());
if (!block.getHash().equals(mainBlock.getHash())) {
return null;
}
txInfo.setTransaction(block.getTransactionsList().get(txInfo.getIndex()));
}
if (txInfo == null) {
return null;
}
return s = new TransactionResultDTO(block, txInfo.getIndex(), txInfo.getReceipt().getTransaction());
} finally {
logger.debug("eth_getTransactionByHash({}): {}", transactionHash, s);
}
}
Aggregations