diff --git a/src/main/java/io/bitsquare/gui/main/preferences/network/NetworkPreferencesPM.java b/src/main/java/io/bitsquare/gui/main/preferences/network/NetworkPreferencesPM.java index 7c7adab3fe..e0625e61ef 100644 --- a/src/main/java/io/bitsquare/gui/main/preferences/network/NetworkPreferencesPM.java +++ b/src/main/java/io/bitsquare/gui/main/preferences/network/NetworkPreferencesPM.java @@ -19,7 +19,7 @@ package io.bitsquare.gui.main.preferences.network; import io.bitsquare.BitsquareException; import io.bitsquare.gui.PresentationModel; -import io.bitsquare.msg.tomp2p.BootstrappedPeerDHTBuilder; +import io.bitsquare.msg.tomp2p.BootstrappedPeerFactory; import io.bitsquare.msg.tomp2p.TomP2PNode; import io.bitsquare.network.BootstrapState; import io.bitsquare.network.Node; @@ -49,9 +49,9 @@ public class NetworkPreferencesPM extends PresentationModel { @Inject NetworkPreferencesPM(NetworkParameters networkParameters, - BootstrappedPeerDHTBuilder bootstrappedPeerDHTBuilder, + BootstrappedPeerFactory bootstrappedPeerFactory, TomP2PNode tomP2PNode, - @Named(BootstrappedPeerDHTBuilder.BOOTSTRAP_NODE_KEY) Node bootstrapNode) { + @Named(BootstrappedPeerFactory.BOOTSTRAP_NODE_KEY) Node bootstrapNode) { switch (networkParameters.getId()) { case NetworkParameters.ID_REGTEST: @@ -77,7 +77,7 @@ public class NetworkPreferencesPM extends PresentationModel { + ", IP: " + bootstrapNode.getIp() + ", Port: " + bootstrapNode.getPortAsString(); - BootstrapState state = bootstrappedPeerDHTBuilder.bootstrapState.get(); + BootstrapState state = bootstrappedPeerFactory.bootstrapState.get(); if (state == BootstrapState.DIRECT_SUCCESS) p2pNetworkConnection = "Direct connection"; else if (state == BootstrapState.NAT_SUCCESS) diff --git a/src/main/java/io/bitsquare/msg/tomp2p/BootstrappedPeerDHTBuilder.java b/src/main/java/io/bitsquare/msg/tomp2p/BootstrappedPeerFactory.java similarity index 96% rename from src/main/java/io/bitsquare/msg/tomp2p/BootstrappedPeerDHTBuilder.java rename to src/main/java/io/bitsquare/msg/tomp2p/BootstrappedPeerFactory.java index 8af52d2819..561ecccaa9 100644 --- a/src/main/java/io/bitsquare/msg/tomp2p/BootstrappedPeerDHTBuilder.java +++ b/src/main/java/io/bitsquare/msg/tomp2p/BootstrappedPeerFactory.java @@ -70,8 +70,8 @@ import org.slf4j.LoggerFactory; /** * Creates a DHT peer and bootstraps to the network via a bootstrap node */ -public class BootstrappedPeerDHTBuilder { - private static final Logger log = LoggerFactory.getLogger(BootstrappedPeerDHTBuilder.class); +public class BootstrappedPeerFactory { + private static final Logger log = LoggerFactory.getLogger(BootstrappedPeerFactory.class); public static final String BOOTSTRAP_NODE_KEY = "bootstrapNode"; static final String NETWORK_INTERFACE_KEY = "interface"; @@ -94,10 +94,10 @@ public class BootstrappedPeerDHTBuilder { /////////////////////////////////////////////////////////////////////////////////////////// @Inject - public BootstrappedPeerDHTBuilder(Persistence persistence, - @Named(Node.PORT_KEY) int port, - @Named(BOOTSTRAP_NODE_KEY) Node bootstrapNode, - @Named(NETWORK_INTERFACE_KEY) String networkInterface) { + public BootstrappedPeerFactory(Persistence persistence, + @Named(Node.PORT_KEY) int port, + @Named(BOOTSTRAP_NODE_KEY) Node bootstrapNode, + @Named(NETWORK_INTERFACE_KEY) String networkInterface) { this.persistence = persistence; this.port = port; this.bootstrapNode = bootstrapNode; @@ -314,7 +314,7 @@ public class BootstrappedPeerDHTBuilder { public void operationComplete(BaseFuture future) throws Exception { if (futureBootstrap.isSuccess()) { setState(state, "Bootstrap successful."); - persistence.write(BootstrappedPeerDHTBuilder.this, "lastSuccessfulBootstrap", state); + persistence.write(BootstrappedPeerFactory.this, "lastSuccessfulBootstrap", state); settableFuture.set(peerDHT); } else { diff --git a/src/main/java/io/bitsquare/msg/tomp2p/TomP2PMessageModule.java b/src/main/java/io/bitsquare/msg/tomp2p/TomP2PMessageModule.java index 021a20b48b..1364a6d7ff 100644 --- a/src/main/java/io/bitsquare/msg/tomp2p/TomP2PMessageModule.java +++ b/src/main/java/io/bitsquare/msg/tomp2p/TomP2PMessageModule.java @@ -26,14 +26,14 @@ import com.google.inject.name.Names; import org.springframework.core.env.Environment; -import static io.bitsquare.msg.tomp2p.BootstrappedPeerDHTBuilder.*; +import static io.bitsquare.msg.tomp2p.BootstrappedPeerFactory.*; public class TomP2PMessageModule extends MessageModule { public static final String BOOTSTRAP_NODE_NAME_KEY = "bootstrap.node.name"; public static final String BOOTSTRAP_NODE_IP_KEY = "bootstrap.node.ip"; public static final String BOOTSTRAP_NODE_PORT_KEY = "bootstrap.node.port"; - public static final String NETWORK_INTERFACE_KEY = BootstrappedPeerDHTBuilder.NETWORK_INTERFACE_KEY; + public static final String NETWORK_INTERFACE_KEY = BootstrappedPeerFactory.NETWORK_INTERFACE_KEY; public TomP2PMessageModule(Environment env) { super(env); @@ -54,7 +54,7 @@ public class TomP2PMessageModule extends MessageModule { ); bindConstant().annotatedWith(Names.named(NETWORK_INTERFACE_KEY)).to( env.getProperty(NETWORK_INTERFACE_KEY, NETWORK_INTERFACE_UNSPECIFIED)); - bind(BootstrappedPeerDHTBuilder.class).asEagerSingleton(); + bind(BootstrappedPeerFactory.class).asEagerSingleton(); } @Override diff --git a/src/main/java/io/bitsquare/msg/tomp2p/TomP2PNode.java b/src/main/java/io/bitsquare/msg/tomp2p/TomP2PNode.java index 113cee03da..5723de6eb2 100644 --- a/src/main/java/io/bitsquare/msg/tomp2p/TomP2PNode.java +++ b/src/main/java/io/bitsquare/msg/tomp2p/TomP2PNode.java @@ -76,7 +76,7 @@ public class TomP2PNode { private PeerAddress storedPeerAddress; private PeerDHT peerDHT; - private BootstrappedPeerDHTBuilder bootstrappedPeerDHTBuilder; + private BootstrappedPeerFactory bootstrappedPeerFactory; /////////////////////////////////////////////////////////////////////////////////////////// @@ -84,8 +84,8 @@ public class TomP2PNode { /////////////////////////////////////////////////////////////////////////////////////////// @Inject - public TomP2PNode(BootstrappedPeerDHTBuilder bootstrappedPeerDHTBuilder) { - this.bootstrappedPeerDHTBuilder = bootstrappedPeerDHTBuilder; + public TomP2PNode(BootstrappedPeerFactory bootstrappedPeerFactory) { + this.bootstrappedPeerFactory = bootstrappedPeerFactory; } // for unit testing @@ -108,17 +108,17 @@ public class TomP2PNode { public void setKeyPair(@NotNull KeyPair keyPair) { this.keyPair = keyPair; - bootstrappedPeerDHTBuilder.setKeyPair(keyPair); + bootstrappedPeerFactory.setKeyPair(keyPair); } public void bootstrap(BootstrapListener bootstrapListener) { checkNotNull(keyPair, "keyPair must not be null."); checkNotNull(messageBroker, "messageBroker must not be null."); - bootstrappedPeerDHTBuilder.bootstrapState.addListener((ov, oldValue, newValue) -> + bootstrappedPeerFactory.bootstrapState.addListener((ov, oldValue, newValue) -> bootstrapListener.onBootstrapStateChanged(newValue)); - SettableFuture bootstrapFuture = bootstrappedPeerDHTBuilder.start(); + SettableFuture bootstrapFuture = bootstrappedPeerFactory.start(); Futures.addCallback(bootstrapFuture, new FutureCallback() { @Override public void onSuccess(@Nullable PeerDHT peerDHT) { @@ -149,7 +149,7 @@ public class TomP2PNode { } public void shutDown() { - bootstrappedPeerDHTBuilder.shutDown(); + bootstrappedPeerFactory.shutDown(); if (peerDHT != null) peerDHT.shutdown();