Skip to content

Commit

Permalink
BtcNetworkConfig: Shuffle Bitcoin Core peers
Browse files Browse the repository at this point in the history
We try to connect to the first 7 Bitcoin Core nodes always in the same
order. Only if connections to these nodes fail we look further into the
list. This change shuffles the node addresses before passing them to
BitcoinJ thus removing the bias from the first 7 prioritized nodes.
  • Loading branch information
alvasw committed Nov 14, 2024
1 parent 1e3e70e commit 56a0bef
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/main/java/bisq/core/btc/nodes/BtcNetworkConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import com.runjva.sourceforge.jsocks.protocol.Socks5Proxy;

import java.util.Collections;
import java.util.List;

import org.slf4j.Logger;
Expand Down Expand Up @@ -56,6 +57,7 @@ public BtcNetworkConfig(WalletConfig delegate, NetworkParameters parameters, int
public void proposePeers(List<PeerAddress> peers) {
if (!peers.isEmpty()) {
log.info("You connect with peerAddresses: {}", peers);
Collections.shuffle(peers);
PeerAddress[] peerAddresses = peers.toArray(new PeerAddress[0]);
delegate.setPeerNodes(peerAddresses);
} else if (proxy != null) {
Expand Down

0 comments on commit 56a0bef

Please sign in to comment.