Skip to content

Commit

Permalink
7582: Put AbstractSyncTargetManager.waitForPeerAndThenSetSyncTarget c…
Browse files Browse the repository at this point in the history
…ode back separate thread to avoid infinite loop waiting for peers during acceptance tests

Signed-off-by: Matilda Clerke <[email protected]>
  • Loading branch information
Matilda-Clerke committed Dec 13, 2024
1 parent abc4cb4 commit beeca44
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.plugin.services.MetricsSystem;

import java.time.Duration;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import org.slf4j.Logger;
Expand Down Expand Up @@ -117,10 +117,15 @@ protected Optional<SyncTarget> finalizeSelectedSyncTarget(final SyncTarget syncT

private CompletableFuture<SyncTarget> waitForPeerAndThenSetSyncTarget() {
return ethContext
.getEthPeers()
.waitForPeer((peer) -> true)
.orTimeout(5, TimeUnit.SECONDS)
.thenCompose((r) -> findSyncTarget());
.getScheduler()
.scheduleFutureTask(
() ->
ethContext
.getEthPeers()
.waitForPeer((peer) -> true)
.handle((ignored, ignored2) -> null)
.thenCompose((r) -> findSyncTarget()),
Duration.ofSeconds(5));
}

private boolean isCancelled() {
Expand Down

0 comments on commit beeca44

Please sign in to comment.