From a8b4ef8194ca73d2fc744bf9be9587ac91ff3605 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Thu, 14 Nov 2024 01:58:21 +0000 Subject: [PATCH] BtcNetworkConfig: Shuffle Bitcoin Core peers 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. --- core/src/main/java/bisq/core/btc/nodes/BtcNetworkConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/java/bisq/core/btc/nodes/BtcNetworkConfig.java b/core/src/main/java/bisq/core/btc/nodes/BtcNetworkConfig.java index 0677e455bd..cf37e35e9b 100644 --- a/core/src/main/java/bisq/core/btc/nodes/BtcNetworkConfig.java +++ b/core/src/main/java/bisq/core/btc/nodes/BtcNetworkConfig.java @@ -29,6 +29,7 @@ import org.bitcoinj.params.MainNetParams; import com.runjva.sourceforge.jsocks.protocol.Socks5Proxy; +import java.util.Collections; import java.util.List; import org.slf4j.Logger; @@ -56,6 +57,7 @@ public class BtcNetworkConfig { public void proposePeers(List 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) {