Skip to content

Commit

Permalink
PeerGroup: Limit number of Bitcoin network peers at re-connect after …
Browse files Browse the repository at this point in the history
…connection loss

Cherry pick bisq-network@e112b13
Cherry pick bisq-network@093d5e4
Cherry pick bisq-network@cbac863
  • Loading branch information
oscarguindzberg committed Dec 20, 2018
1 parent 91ab651 commit 84ac33a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/src/main/java/org/bitcoinj/core/PeerGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,12 @@ public void go() {
executor.schedule(this, delay, TimeUnit.MILLISECONDS);
return;
}
connectTo(addrToTry, false, vConnectTimeoutMillis);

// 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)
connectTo(addrToTry, false, vConnectTimeoutMillis);
} finally {
lock.unlock();
}
Expand Down

0 comments on commit 84ac33a

Please sign in to comment.