From aca80585f459103c2b9ebc0e80c8fc0e737a8e3d Mon Sep 17 00:00:00 2001 From: Matilda Clerke Date: Wed, 2 Oct 2024 16:28:18 +1000 Subject: [PATCH] 7311: More changes in DownloadReceiptsStep Signed-off-by: Matilda Clerke --- .../eth/sync/fastsync/DownloadReceiptsStep.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStep.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStep.java index d1fc60b937..407effb7e0 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStep.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStep.java @@ -32,7 +32,6 @@ import org.hyperledger.besu.ethereum.mainnet.BodyValidator; import org.hyperledger.besu.plugin.services.MetricsSystem; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -64,23 +63,16 @@ public class DownloadReceiptsStep () -> { List blockWithReceiptsList = new ArrayList<>(headers.size()); do { - final Map> getReceipts = - new HashMap>(); GetReceiptsFromPeerTask getReceiptsFromPeerTask = new GetReceiptsFromPeerTask(headers, new BodyValidator()); PeerTaskExecutorResult>> getReceiptsResult = peerTaskExecutor.execute(getReceiptsFromPeerTask); if (getReceiptsResult.responseCode() == PeerTaskExecutorResponseCode.SUCCESS && getReceiptsResult.result().isPresent()) { - Map> receiptsResult = - getReceiptsResult.result().get(); - for (BlockHeader blockHeader : receiptsResult.keySet()) { - getReceipts.put(blockHeader, receiptsResult.get(blockHeader)); - } + // remove all the headers we found receipts for + headers.removeAll(getReceiptsResult.result().get().keySet()); + blockWithReceiptsList.addAll(combineBlocksAndReceipts(blocks, getReceiptsResult.result().get())); } - // remove all the headers we found receipts for - headers.removeAll(getReceipts.keySet()); - blockWithReceiptsList.addAll(combineBlocksAndReceipts(blocks, getReceipts)); // repeat until all headers have receipts } while (!headers.isEmpty()); @@ -101,7 +93,7 @@ public class DownloadReceiptsStep private List combineBlocksAndReceipts( final List blocks, final Map> receiptsByHeader) { return blocks.stream() - .filter((b) -> receiptsByHeader.keySet().contains(b.getHeader())) + .filter((b) -> receiptsByHeader.containsKey(b.getHeader())) .map( block -> { final List receipts =