diff --git a/core/src/main/java/org/bitcoinj/core/PeerGroup.java b/core/src/main/java/org/bitcoinj/core/PeerGroup.java index eba10be248d..41d0b75f47d 100644 --- a/core/src/main/java/org/bitcoinj/core/PeerGroup.java +++ b/core/src/main/java/org/bitcoinj/core/PeerGroup.java @@ -640,17 +640,6 @@ public void go() { } }; - private boolean isAlreadyAdded(PeerAddress peerAddress) { - boolean isAlreadyAdded = false; - for (PeerAddress a : inactives) { - if (a.getHostname() != null && a.getHostname().equals(peerAddress.getHostname())) { - isAlreadyAdded = true; - break; - } - } - return isAlreadyAdded; - } - private void triggerConnections() { // Run on a background thread due to the need to potentially retry and back off in the background. if (!executor.isShutdown()) @@ -1876,7 +1865,14 @@ protected void handlePeerDeath(final Peer peer, @Nullable Throwable exception) { } else { backoffMap.get(address).trackFailure(); // Put back on inactive list - if (!isAlreadyAdded(address)) { + boolean inactiveContainsAddress = false; + for (PeerAddress a : inactives) { + if (a.equalsIgnoringMetadata(address)) { + inactiveContainsAddress = true; + break; + } + } + if (!inactiveContainsAddress) { inactives.offer(address); } }