mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-20 07:46:05 -04:00
Pass max connections to `SeedNode.createAndStartP2PService()
`
Still keep calls to ``PeerManager.setMaxConnections()`` until it is retired.
This commit is contained in:
parent
f0aec0d55c
commit
dc90a950cb
@ -30,6 +30,7 @@ public class SeedNode {
|
||||
public static final int MAX_CONNECTIONS_DEFAULT = 50;
|
||||
|
||||
private NodeAddress mySeedNodeAddress = new NodeAddress("localhost:8001");
|
||||
private int maxConnections = MAX_CONNECTIONS_DEFAULT; // we keep default a higher connection size for seed nodes
|
||||
private boolean useLocalhost = false;
|
||||
private Set<NodeAddress> progArgSeedNodes;
|
||||
private P2PService seedNodeP2PService;
|
||||
@ -67,13 +68,10 @@ public class SeedNode {
|
||||
Version.setBtcNetworkId(networkId);
|
||||
if (args.length > 2) {
|
||||
String arg2 = args[2];
|
||||
int maxConnections = Integer.parseInt(arg2);
|
||||
maxConnections = Integer.parseInt(arg2);
|
||||
log.info("From processArgs: maxConnections=" + maxConnections);
|
||||
checkArgument(maxConnections < MAX_CONNECTIONS_LIMIT, "maxConnections seems to be a bit too high...");
|
||||
PeerManager.setMaxConnections(maxConnections);
|
||||
} else {
|
||||
// we keep default a higher connection size for seed nodes
|
||||
PeerManager.setMaxConnections(MAX_CONNECTIONS_DEFAULT);
|
||||
}
|
||||
if (args.length > 3) {
|
||||
String arg3 = args[3];
|
||||
@ -107,11 +105,13 @@ public class SeedNode {
|
||||
}
|
||||
|
||||
public void createAndStartP2PService(boolean useDetailedLogging) {
|
||||
createAndStartP2PService(mySeedNodeAddress, useLocalhost, Version.getBtcNetworkId(), useDetailedLogging, progArgSeedNodes, null);
|
||||
createAndStartP2PService(mySeedNodeAddress, maxConnections, useLocalhost,
|
||||
Version.getBtcNetworkId(), useDetailedLogging, progArgSeedNodes, null);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void createAndStartP2PService(NodeAddress mySeedNodeAddress,
|
||||
int maxConnections,
|
||||
boolean useLocalhost,
|
||||
int networkId,
|
||||
boolean useDetailedLogging,
|
||||
@ -144,7 +144,8 @@ public class SeedNode {
|
||||
log.info("Created torDir at " + torDir.getAbsolutePath());
|
||||
|
||||
seedNodesRepository.setNodeAddressToExclude(mySeedNodeAddress);
|
||||
seedNodeP2PService = new P2PService(seedNodesRepository, mySeedNodeAddress.port, torDir, useLocalhost, networkId, storageDir, new Clock(), null, null);
|
||||
seedNodeP2PService = new P2PService(seedNodesRepository, mySeedNodeAddress.port, maxConnections,
|
||||
torDir, useLocalhost, networkId, storageDir, new Clock(), null, null);
|
||||
seedNodeP2PService.start(listener);
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import java.util.concurrent.CountDownLatch;
|
||||
// Run it once then lookup for onion address at: tor/hiddenservice/hostname and use that for the NodeAddress param.
|
||||
public class PeerServiceTest {
|
||||
private static final Logger log = LoggerFactory.getLogger(PeerServiceTest.class);
|
||||
public static final int MAX_CONNECTIONS = 100;
|
||||
|
||||
final boolean useLocalhost = true;
|
||||
private CountDownLatch latch;
|
||||
@ -37,7 +38,7 @@ public class PeerServiceTest {
|
||||
public void setup() throws InterruptedException {
|
||||
LocalhostNetworkNode.setSimulateTorDelayTorNode(50);
|
||||
LocalhostNetworkNode.setSimulateTorDelayHiddenService(8);
|
||||
PeerManager.setMaxConnections(100);
|
||||
PeerManager.setMaxConnections(MAX_CONNECTIONS);
|
||||
|
||||
if (useLocalhost) {
|
||||
seedNodeAddresses.add(new NodeAddress("localhost:8001"));
|
||||
@ -127,7 +128,7 @@ public class PeerServiceTest {
|
||||
|
||||
/* latch = new CountDownLatch(2);
|
||||
|
||||
seedNode.createAndStartP2PService(nodeAddress, useLocalhost, 2, true,
|
||||
seedNode.createAndStartP2PService(nodeAddress, MAX_CONNECTIONS, useLocalhost, 2, true,
|
||||
seedNodeAddresses, new P2PServiceListener() {
|
||||
@Override
|
||||
public void onRequestingDataCompleted() {
|
||||
@ -181,7 +182,7 @@ public class PeerServiceTest {
|
||||
latch = new CountDownLatch(6);
|
||||
|
||||
seedNode1 = new SeedNode("test_dummy_dir");
|
||||
seedNode1.createAndStartP2PService(nodeAddress1, useLocalhost, 2, true, seedNodeAddresses, new P2PServiceListener() {
|
||||
seedNode1.createAndStartP2PService(nodeAddress1, MAX_CONNECTIONS, useLocalhost, 2, true, seedNodeAddresses, new P2PServiceListener() {
|
||||
@Override
|
||||
public void onRequestingDataCompleted() {
|
||||
latch.countDown();
|
||||
@ -219,7 +220,7 @@ public class PeerServiceTest {
|
||||
Thread.sleep(500);
|
||||
|
||||
seedNode2 = new SeedNode("test_dummy_dir");
|
||||
seedNode2.createAndStartP2PService(nodeAddress2, useLocalhost, 2, true, seedNodeAddresses, new P2PServiceListener() {
|
||||
seedNode2.createAndStartP2PService(nodeAddress2, MAX_CONNECTIONS, useLocalhost, 2, true, seedNodeAddresses, new P2PServiceListener() {
|
||||
@Override
|
||||
public void onRequestingDataCompleted() {
|
||||
latch.countDown();
|
||||
@ -456,7 +457,7 @@ public class PeerServiceTest {
|
||||
SeedNode seedNode = new SeedNode("test_dummy_dir");
|
||||
|
||||
latch = new CountDownLatch(1);
|
||||
seedNode.createAndStartP2PService(new NodeAddress("localhost", port), useLocalhost, 2, true, seedNodeAddresses, new P2PServiceListener() {
|
||||
seedNode.createAndStartP2PService(new NodeAddress("localhost", port), MAX_CONNECTIONS, useLocalhost, 2, true, seedNodeAddresses, new P2PServiceListener() {
|
||||
@Override
|
||||
public void onRequestingDataCompleted() {
|
||||
latch.countDown();
|
||||
|
@ -82,7 +82,7 @@ public class TestUtils {
|
||||
}
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
seedNode.createAndStartP2PService(new NodeAddress("localhost", port), useLocalhost, 2, true,
|
||||
seedNode.createAndStartP2PService(new NodeAddress("localhost", port), SeedNode.MAX_CONNECTIONS_DEFAULT, useLocalhost, 2, true,
|
||||
seedNodes, new P2PServiceListener() {
|
||||
@Override
|
||||
public void onRequestingDataCompleted() {
|
||||
|
@ -26,6 +26,7 @@ import java.util.concurrent.CountDownLatch;
|
||||
@Ignore
|
||||
public class PeerManagerTest {
|
||||
private static final Logger log = LoggerFactory.getLogger(PeerManagerTest.class);
|
||||
public static final int MAX_CONNECTIONS = 100;
|
||||
|
||||
final boolean useLocalhost = true;
|
||||
private CountDownLatch latch;
|
||||
@ -37,7 +38,7 @@ public class PeerManagerTest {
|
||||
public void setup() throws InterruptedException {
|
||||
LocalhostNetworkNode.setSimulateTorDelayTorNode(50);
|
||||
LocalhostNetworkNode.setSimulateTorDelayHiddenService(8);
|
||||
PeerManager.setMaxConnections(100);
|
||||
PeerManager.setMaxConnections(MAX_CONNECTIONS);
|
||||
|
||||
seedNodes = new HashSet<>();
|
||||
if (useLocalhost) {
|
||||
@ -84,7 +85,7 @@ public class PeerManagerTest {
|
||||
seedNodes.add(nodeAddress);
|
||||
seedNode1 = new SeedNode("test_dummy_dir");
|
||||
latch = new CountDownLatch(2);
|
||||
seedNode1.createAndStartP2PService(nodeAddress, useLocalhost, 2, true,
|
||||
seedNode1.createAndStartP2PService(nodeAddress, MAX_CONNECTIONS, useLocalhost, 2, true,
|
||||
seedNodes, new P2PServiceListener() {
|
||||
@Override
|
||||
public void onRequestingDataCompleted() {
|
||||
@ -136,7 +137,7 @@ public class PeerManagerTest {
|
||||
latch = new CountDownLatch(6);
|
||||
|
||||
seedNode1 = new SeedNode("test_dummy_dir");
|
||||
seedNode1.createAndStartP2PService(nodeAddress1, useLocalhost, 2, true, seedNodes, new P2PServiceListener() {
|
||||
seedNode1.createAndStartP2PService(nodeAddress1, MAX_CONNECTIONS, useLocalhost, 2, true, seedNodes, new P2PServiceListener() {
|
||||
@Override
|
||||
public void onRequestingDataCompleted() {
|
||||
latch.countDown();
|
||||
@ -174,7 +175,7 @@ public class PeerManagerTest {
|
||||
Thread.sleep(500);
|
||||
|
||||
seedNode2 = new SeedNode("test_dummy_dir");
|
||||
seedNode2.createAndStartP2PService(nodeAddress2, useLocalhost, 2, true, seedNodes, new P2PServiceListener() {
|
||||
seedNode2.createAndStartP2PService(nodeAddress2, MAX_CONNECTIONS, useLocalhost, 2, true, seedNodes, new P2PServiceListener() {
|
||||
@Override
|
||||
public void onRequestingDataCompleted() {
|
||||
latch.countDown();
|
||||
@ -411,7 +412,7 @@ public class PeerManagerTest {
|
||||
SeedNode seedNode = new SeedNode("test_dummy_dir");
|
||||
|
||||
latch = new CountDownLatch(1);
|
||||
seedNode.createAndStartP2PService(new NodeAddress("localhost", port), useLocalhost, 2, true, seedNodes, new P2PServiceListener() {
|
||||
seedNode.createAndStartP2PService(new NodeAddress("localhost", port), MAX_CONNECTIONS, useLocalhost, 2, true, seedNodes, new P2PServiceListener() {
|
||||
@Override
|
||||
public void onRequestingDataCompleted() {
|
||||
latch.countDown();
|
||||
|
Loading…
x
Reference in New Issue
Block a user