Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
When retrieving transactions by hash, check the pending transactions …
Browse files Browse the repository at this point in the history
…first. (#1542)

Previously it was possible for a transaction to be "missed" by this call if it was added to a block between when we checked the blockchain and when we checked the pending transaction pool.
  • Loading branch information
ajsutton authored Jun 10, 2019
1 parent e054095 commit a7bb9eb
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@ public JsonRpcResponse response(final JsonRpcRequest request) {
}

private Object getResult(final Hash hash) {
final Optional<Object> transactionCompleteResult =
blockchain.transactionByHash(hash).map(TransactionCompleteResult::new);
return transactionCompleteResult.orElseGet(
() ->
pendingTransactions
.getTransactionByHash(hash)
.map(TransactionPendingResult::new)
.orElse(null));
final Optional<Object> transactionPendingResult =
pendingTransactions.getTransactionByHash(hash).map(TransactionPendingResult::new);
return transactionPendingResult.orElseGet(
() -> blockchain.transactionByHash(hash).map(TransactionCompleteResult::new).orElse(null));
}
}

0 comments on commit a7bb9eb

Please sign in to comment.