由于web3j没有实现getPendingTransactions
接口,业务又需要,所以补充下
参考下web3.js (Github Code)
new Method({
name: 'getPendingTransactions',
call: 'eth_pendingTransactions',
params: 0,
outputFormatter: formatter.outputTransactionFormatter
}),
通过查询(Github Code)
找到以下轮子 (Github Code)
@Override
public List<Transaction> getPendingTransactions() throws EthereumException {
// only works if a gexp node is used (pending transaction sent by one of the gexp accounts are returned)
LOG.info("Get pending transactions sent by addr");
JsonRpcRequest jsonRpcRequest = new JsonRpcRequest();
jsonRpcRequest.setId(0);
jsonRpcRequest.setMethod("eth_pendingTransactions");
jsonRpcRequest.setJsonrpc("2.0");
HttpEntity<JsonRpcRequest> request = new HttpEntity<>(jsonRpcRequest);
PendingTransactionResponse response = doPOST(getNodeBaseUrl(), request, PendingTransactionResponse.class);
List<Transaction> pendingTransactions = response
.getPendingTransactions()
.parallelStream()
.map(DtoConverter::convert)
.collect(Collectors.toList());
LOG.info("Pending transactions found: " + pendingTransactions.size());
return pendingTransactions;
}
如果完整的,应该fork扩充到 (Github Code)
版权属于:区块链中文技术社区 / 转载原创者
本文链接:https://bcskill.com/index.php/archives/1132.html
相关技术文章仅限于相关区块链底层技术研究,禁止用于非法用途,后果自负!本站严格遵守一切相关法律政策!