From a9122cc6cb904c7de6cd3b6c881b3bbcabb34fae Mon Sep 17 00:00:00 2001 From: catbref Date: Wed, 21 Aug 2019 09:45:41 +0100 Subject: [PATCH] Improve choosing which peer to connect to --- src/main/java/org/qora/network/Network.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/qora/network/Network.java b/src/main/java/org/qora/network/Network.java index 3344f004..ce7e160c 100644 --- a/src/main/java/org/qora/network/Network.java +++ b/src/main/java/org/qora/network/Network.java @@ -591,7 +591,10 @@ public class Network extends Thread { // Don't consider peers with recent connection failures final long lastAttemptedThreshold = now - CONNECT_FAILURE_BACKOFF; - peers.removeIf(peerData -> peerData.getLastAttempted() != null && peerData.getLastAttempted() > lastAttemptedThreshold); + peers.removeIf(peerData -> peerData.getLastAttempted() != null && + peerData.getLastConnected() != null && + peerData.getLastConnected() < peerData.getLastAttempted() && + peerData.getLastAttempted() > lastAttemptedThreshold); // Don't consider peers that we know loop back to ourself Predicate isSelfPeer = peerData -> {