Add maxConnection program arg

This commit is contained in:
Manfred Karrer 2016-06-09 18:40:19 +02:00
parent fd4b6a02cd
commit 12e56fbd8b
5 changed files with 12 additions and 2 deletions

View File

@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory;
public class DevFlags {
private static final Logger log = LoggerFactory.getLogger(DevFlags.class);
public static final boolean STRESS_TEST_MODE = false;
public static final boolean STRESS_TEST_MODE = true;
public static final boolean DEV_MODE = STRESS_TEST_MODE || false;
public static final boolean IS_RELEASE_VERSION = !DEV_MODE && true;

View File

@ -8,6 +8,7 @@ public class ProgramArguments {
// program arg names
public static final String TOR_DIR = "torDir";
public static final String USE_LOCALHOST = "useLocalhost";
public static final String MAX_CONNECTIONS = "maxConnections";
public static final String NAME_KEY = "node.name";

View File

@ -20,6 +20,7 @@ package io.bitsquare.app;
import io.bitsquare.BitsquareException;
import io.bitsquare.btc.BitcoinNetwork;
import io.bitsquare.btc.RegTestHost;
import io.bitsquare.p2p.P2PService;
import io.bitsquare.util.joptsimple.EnumValueConverter;
import joptsimple.OptionException;
import joptsimple.OptionParser;
@ -106,6 +107,9 @@ public class BitsquareAppMain extends BitsquareExecutable {
parser.accepts(ProgramArguments.USE_LOCALHOST, description("Use localhost network for development", false))
.withRequiredArg()
.ofType(boolean.class);
parser.accepts(ProgramArguments.MAX_CONNECTIONS, description("Max. connections a peer will try to keep", P2PService.MAX_CONNECTIONS_DEFAULT))
.withRequiredArg()
.ofType(int.class);
parser.accepts(BitcoinNetwork.KEY, description("Bitcoin network", BitcoinNetwork.DEFAULT))
.withRequiredArg()
.ofType(BitcoinNetwork.class)

View File

@ -50,6 +50,9 @@ public class P2PModule extends AppModule {
Integer port = env.getProperty(ProgramArguments.PORT_KEY, int.class, 9999);
bind(int.class).annotatedWith(Names.named(ProgramArguments.PORT_KEY)).toInstance(port);
Integer maxConnections = env.getProperty(ProgramArguments.MAX_CONNECTIONS, int.class, P2PService.MAX_CONNECTIONS_DEFAULT);
bind(int.class).annotatedWith(Names.named(ProgramArguments.MAX_CONNECTIONS)).toInstance(maxConnections);
Integer networkId = env.getProperty(ProgramArguments.NETWORK_ID, int.class, 1);
bind(int.class).annotatedWith(Names.named(ProgramArguments.NETWORK_ID)).toInstance(networkId);
}

View File

@ -102,13 +102,15 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
@Named(ProgramArguments.TOR_DIR) File torDir,
@Named(ProgramArguments.USE_LOCALHOST) boolean useLocalhost,
@Named(ProgramArguments.NETWORK_ID) int networkId,
@Named(ProgramArguments.MAX_CONNECTIONS) int maxConnections,
@Named("storage.dir") File storageDir,
Clock clock,
@Nullable EncryptionService encryptionService,
@Nullable KeyRing keyRing) {
this(
seedNodesRepository,
port, MAX_CONNECTIONS_DEFAULT,
port,
maxConnections,
torDir,
useLocalhost,
networkId,