diff --git a/core/src/main/java/org/bitcoinj/core/PeerGroup.java b/core/src/main/java/org/bitcoinj/core/PeerGroup.java index 41d0b75f47d..9522763f475 100644 --- a/core/src/main/java/org/bitcoinj/core/PeerGroup.java +++ b/core/src/main/java/org/bitcoinj/core/PeerGroup.java @@ -629,7 +629,7 @@ public void go() { // BitcoinJ gets too many connections after a connection loss and reconnect as it adds up a lot of // potential candidates and then try to connect to all of those when getting connection again. // A check for maxConnections is required to not exceed connections. - if(pendingPeers.size() + peers.size() < maxConnections) + if (countConnectedAndPendingPeers() < getMaxConnections()) connectTo(addrToTry, false, vConnectTimeoutMillis); } finally { lock.unlock();