Add internal `P2PService` constructor with (unused) maximum connections argument

The value of ``P2PService.MAX_CONNECTIONS_DEFAULT`` is taken from the static block invocation of ``PeerManager.setMaxConnections()``.
This commit is contained in:
Ivan Vilata-i-Balaguer 2016-05-06 09:39:47 +02:00
parent a50bf41803
commit f0aec0d55c

View File

@ -55,9 +55,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
public class P2PService implements SetupListener, MessageListener, ConnectionListener, RequestDataManager.Listener,
HashMapChangedListener {
private static final Logger log = LoggerFactory.getLogger(P2PService.class);
public static final int MAX_CONNECTIONS_DEFAULT = 12;
private final SeedNodesRepository seedNodesRepository;
private final int port;
private final int maxConnections;
private final File torDir;
private Clock clock;
private final Optional<EncryptionService> optionalEncryptionService;
@ -104,8 +106,32 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
Clock clock,
@Nullable EncryptionService encryptionService,
@Nullable KeyRing keyRing) {
this(
seedNodesRepository,
port, MAX_CONNECTIONS_DEFAULT,
torDir,
useLocalhost,
networkId,
storageDir,
clock,
encryptionService,
keyRing
);
}
@VisibleForTesting
public P2PService(SeedNodesRepository seedNodesRepository,
int port, int maxConnections,
File torDir,
boolean useLocalhost,
int networkId,
File storageDir,
Clock clock,
@Nullable EncryptionService encryptionService,
@Nullable KeyRing keyRing) {
this.seedNodesRepository = seedNodesRepository;
this.port = port;
this.maxConnections = maxConnections;
this.torDir = torDir;
this.clock = clock;