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 d4b3f603d1..1d56c61a7e 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,9 +34,9 @@ import java.util.concurrent.TimeoutException; /** Manages the execution of PeerTasks, respecting their PeerTaskRetryBehavior */ 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; + public static final int RETRIES_WITH_SAME_PEER = 2; + public static final int RETRIES_WITH_OTHER_PEER = 2; + public static final int NO_RETRIES = 0; private final PeerSelector peerSelector; private final PeerTaskRequestSender requestSender; private final EthScheduler ethScheduler; @@ -61,7 +61,7 @@ public class PeerTaskExecutor { public PeerTaskExecutorResult execute(final PeerTask peerTask) { PeerTaskExecutorResult executorResult; - int triesRemaining = + int retriesRemaining = peerTask.getPeerTaskRetryBehaviors().contains(PeerTaskRetryBehavior.RETRY_WITH_OTHER_PEERS) ? RETRIES_WITH_OTHER_PEER : NO_RETRIES; @@ -81,7 +81,7 @@ public class PeerTaskExecutor { new PeerTaskExecutorResult<>( Optional.empty(), PeerTaskExecutorResponseCode.NO_PEER_AVAILABLE); } - } while (--triesRemaining > 0 + } while (retriesRemaining-- > 0 && executorResult.responseCode() != PeerTaskExecutorResponseCode.SUCCESS); return executorResult; @@ -96,7 +96,7 @@ public class PeerTaskExecutor { final PeerTask peerTask, final EthPeer peer) { MessageData requestMessageData = peerTask.getRequestMessage(); PeerTaskExecutorResult executorResult; - int triesRemaining = + int retriesRemaining = peerTask.getPeerTaskRetryBehaviors().contains(PeerTaskRetryBehavior.RETRY_WITH_SAME_PEER) ? RETRIES_WITH_SAME_PEER : NO_RETRIES; @@ -136,7 +136,7 @@ public class PeerTaskExecutor { new PeerTaskExecutorResult<>( Optional.empty(), PeerTaskExecutorResponseCode.INTERNAL_SERVER_ERROR); } - } while (--triesRemaining > 0 + } while (retriesRemaining-- > 0 && executorResult.responseCode() != PeerTaskExecutorResponseCode.SUCCESS && executorResult.responseCode() != PeerTaskExecutorResponseCode.PEER_DISCONNECTED && sleepBetweenRetries());