Code cleanup

This commit is contained in:
ChronosX88 2019-05-14 21:21:13 +04:00
parent 44bce216d7
commit 6f0da1e336

View File

@ -51,7 +51,11 @@ public class Main {
try { try {
peerDHT = peerDHT =
new PeerBuilderDHT(new PeerBuilder(peerID).ports(7243).channelClientConfiguration(createClientChannelConfig()).channelServerConfiguration(createServerChannelConfig()).start()) new PeerBuilderDHT(new PeerBuilder(peerID)
.ports(7243)
.channelClientConfiguration(createClientChannelConfig())
.channelServerConfiguration(createServerChannelConfig())
.start())
.storage( .storage(
new StorageMapDB( new StorageMapDB(
peerID, peerID,
@ -70,29 +74,14 @@ public class Main {
} }
private static ChannelClientConfiguration createClientChannelConfig() { private static ChannelClientConfiguration createClientChannelConfig() {
ChannelClientConfiguration channelClientConfiguration = new ChannelClientConfiguration(); ChannelClientConfiguration channelClientConfiguration = PeerBuilder.createDefaultChannelClientConfiguration();
channelClientConfiguration.bindings(new Bindings());
channelClientConfiguration.maxPermitsPermanentTCP(250);
channelClientConfiguration.maxPermitsTCP(250);
channelClientConfiguration.maxPermitsUDP(250);
channelClientConfiguration.pipelineFilter(new PeerBuilder.DefaultPipelineFilter());
channelClientConfiguration.signatureFactory(new RSASignatureFactory()); channelClientConfiguration.signatureFactory(new RSASignatureFactory());
channelClientConfiguration.senderTCP(new InetSocketAddress(0).getAddress());
channelClientConfiguration.senderUDP(new InetSocketAddress(0).getAddress());
channelClientConfiguration.byteBufPool(false);
return channelClientConfiguration; return channelClientConfiguration;
} }
private static ChannelServerConfiguration createServerChannelConfig() { private static ChannelServerConfiguration createServerChannelConfig() {
ChannelServerConfiguration channelServerConfiguration = new ChannelServerConfiguration(); ChannelServerConfiguration channelServerConfiguration = PeerBuilder.createDefaultChannelServerConfiguration();
channelServerConfiguration.bindings(new Bindings());
//these two values may be overwritten in the peer builder
channelServerConfiguration.ports(new Ports(Ports.DEFAULT_PORT, Ports.DEFAULT_PORT));
channelServerConfiguration.portsForwarding(new Ports(Ports.DEFAULT_PORT, Ports.DEFAULT_PORT));
channelServerConfiguration.behindFirewall(false);
channelServerConfiguration.pipelineFilter(new PeerBuilder.DefaultPipelineFilter());
channelServerConfiguration.signatureFactory(new RSASignatureFactory()); channelServerConfiguration.signatureFactory(new RSASignatureFactory());
channelServerConfiguration.byteBufPool(false);
return channelServerConfiguration; return channelServerConfiguration;
} }
} }