From e31bb7003754a8d06d4f4304004ba04514b7b298 Mon Sep 17 00:00:00 2001 From: Matilda Clerke Date: Thu, 26 Sep 2024 16:10:05 +1000 Subject: [PATCH] 7311: Use constants for number of retries Signed-off-by: Matilda Clerke --- .../eth/manager/peertask/PeerTaskExecutor.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskExecutor.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskExecutor.java index fa375d0b62..6fdb89f8c6 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskExecutor.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskExecutor.java @@ -34,6 +34,9 @@ import java.util.function.Supplier; /** Manages the execution of PeerTasks, respecting their PeerTaskBehavior */ public class PeerTaskExecutor { + public static final int RETRIES_WITH_SAME_PEER = 3; + public static final int RETRIES_WITH_OTHER_PEER = 3; + public static final int NO_RETRIES = 1; private final PeerSelector peerSelector; private final PeerTaskRequestSender requestSender; private final Supplier protocolSpecSupplier; @@ -58,7 +61,9 @@ public class PeerTaskExecutor { public PeerTaskExecutorResult execute(final PeerTask peerTask) { PeerTaskExecutorResult executorResult; int triesRemaining = - peerTask.getPeerTaskBehaviors().contains(PeerTaskBehavior.RETRY_WITH_OTHER_PEERS) ? 3 : 1; + peerTask.getPeerTaskBehaviors().contains(PeerTaskBehavior.RETRY_WITH_OTHER_PEERS) + ? RETRIES_WITH_OTHER_PEER + : NO_RETRIES; final Collection usedEthPeers = new ArrayList<>(); do { EthPeer peer; @@ -92,7 +97,9 @@ public class PeerTaskExecutor { MessageData requestMessageData = peerTask.getRequestMessage(); PeerTaskExecutorResult executorResult; int triesRemaining = - peerTask.getPeerTaskBehaviors().contains(PeerTaskBehavior.RETRY_WITH_SAME_PEER) ? 3 : 1; + peerTask.getPeerTaskBehaviors().contains(PeerTaskBehavior.RETRY_WITH_SAME_PEER) + ? RETRIES_WITH_SAME_PEER + : NO_RETRIES; do { try {