mirror of
https://github.com/bisq-network/bisq.git
synced 2025-03-01 01:32:17 +01:00
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.
This commit is contained in:
parent
41912f9417
commit
a8b4ef8194
1 changed files with 2 additions and 0 deletions
|
@ -29,6 +29,7 @@ import org.bitcoinj.params.MainNetParams;
|
||||||
|
|
||||||
import com.runjva.sourceforge.jsocks.protocol.Socks5Proxy;
|
import com.runjva.sourceforge.jsocks.protocol.Socks5Proxy;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -56,6 +57,7 @@ public class BtcNetworkConfig {
|
||||||
public void proposePeers(List<PeerAddress> peers) {
|
public void proposePeers(List<PeerAddress> peers) {
|
||||||
if (!peers.isEmpty()) {
|
if (!peers.isEmpty()) {
|
||||||
log.info("You connect with peerAddresses: {}", peers);
|
log.info("You connect with peerAddresses: {}", peers);
|
||||||
|
Collections.shuffle(peers);
|
||||||
PeerAddress[] peerAddresses = peers.toArray(new PeerAddress[0]);
|
PeerAddress[] peerAddresses = peers.toArray(new PeerAddress[0]);
|
||||||
delegate.setPeerNodes(peerAddresses);
|
delegate.setPeerNodes(peerAddresses);
|
||||||
} else if (proxy != null) {
|
} else if (proxy != null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue