Skip to content

Commit e9401a4

Browse files
Make getTransactions and getReceipts return empty lists when blocks aren't found (#8910)
Signed-off-by: Matilda Clerke <[email protected]>
1 parent bffe025 commit e9401a4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,15 +1222,19 @@ private List<Transaction> getTransactions(
12221222
final Hash blockHash, final Supplier<Boolean> isQueryAlive) throws Exception {
12231223
return BackendQuery.runIfAlive(
12241224
"matchingLogs - getBlockBody",
1225-
() -> blockchain.getBlockBody(blockHash).orElseThrow().getTransactions(),
1225+
() ->
1226+
blockchain
1227+
.getBlockBody(blockHash)
1228+
.map((bb) -> bb.getTransactions())
1229+
.orElse(Collections.emptyList()),
12261230
isQueryAlive);
12271231
}
12281232

12291233
private List<TransactionReceipt> getReceipts(
12301234
final Hash blockHash, final Supplier<Boolean> isQueryAlive) throws Exception {
12311235
return BackendQuery.runIfAlive(
12321236
"matchingLogs - getTxReceipts",
1233-
() -> blockchain.getTxReceipts(blockHash).orElseThrow(),
1237+
() -> blockchain.getTxReceipts(blockHash).orElse(Collections.emptyList()),
12341238
isQueryAlive);
12351239
}
12361240

0 commit comments

Comments
 (0)