From 9bdb4b424988379adebb1808af4bd2cde1f8be5f Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Mon, 10 Nov 2014 08:20:15 +0100 Subject: [PATCH] Move {MessageModule=>BootstrappedPeerFactory}#BOOTSTRAP_NODE_KEY --- src/main/java/io/bitsquare/msg/MessageModule.java | 15 --------------- .../msg/tomp2p/BootstrappedPeerFactory.java | 4 +++- .../bitsquare/msg/tomp2p/TomP2PMessageModule.java | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/java/io/bitsquare/msg/MessageModule.java b/src/main/java/io/bitsquare/msg/MessageModule.java index c396954846..50761b82a5 100644 --- a/src/main/java/io/bitsquare/msg/MessageModule.java +++ b/src/main/java/io/bitsquare/msg/MessageModule.java @@ -18,15 +18,12 @@ package io.bitsquare.msg; import io.bitsquare.BitsquareModule; -import io.bitsquare.network.Node; import com.google.inject.Injector; import com.google.inject.name.Names; import java.util.Properties; -import static io.bitsquare.network.BootstrapNodes.DEFAULT_BOOTSTRAP_NODE; - public abstract class MessageModule extends BitsquareModule { public static final String BOOTSTRAP_NODE_ID_KEY = "id"; @@ -34,8 +31,6 @@ public abstract class MessageModule extends BitsquareModule { public static final String BOOTSTRAP_NODE_PORT_KEY = "port"; public static final String NETWORK_INTERFACE_KEY = "networkInterface"; - public static final String BOOTSTRAP_NODE_KEY = "bootstrapNode"; - protected MessageModule(Properties properties) { super(properties); } @@ -44,16 +39,6 @@ public abstract class MessageModule extends BitsquareModule { protected final void configure() { bind(MessageFacade.class).to(messageFacade()).asEagerSingleton(); - Node bootstrapNode = Node.at( - properties.getProperty(BOOTSTRAP_NODE_ID_KEY, DEFAULT_BOOTSTRAP_NODE.getId()), - properties.getProperty(BOOTSTRAP_NODE_IP_KEY, DEFAULT_BOOTSTRAP_NODE.getIp()), - properties.getProperty(BOOTSTRAP_NODE_PORT_KEY, DEFAULT_BOOTSTRAP_NODE.getPortAsString()) - ); - - bind(Node.class) - .annotatedWith(Names.named(BOOTSTRAP_NODE_KEY)) - .toInstance(bootstrapNode); - bind(String.class) .annotatedWith(Names.named("networkInterface")) .toInstance(properties.getProperty(NETWORK_INTERFACE_KEY, "")); diff --git a/src/main/java/io/bitsquare/msg/tomp2p/BootstrappedPeerFactory.java b/src/main/java/io/bitsquare/msg/tomp2p/BootstrappedPeerFactory.java index 6870021bb5..e463c31fd9 100644 --- a/src/main/java/io/bitsquare/msg/tomp2p/BootstrappedPeerFactory.java +++ b/src/main/java/io/bitsquare/msg/tomp2p/BootstrappedPeerFactory.java @@ -68,7 +68,7 @@ import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static io.bitsquare.msg.MessageModule.BOOTSTRAP_NODE_KEY; + /** * Creates a DHT peer and bootstrap to the network via a seed node @@ -76,6 +76,8 @@ import static io.bitsquare.msg.MessageModule.BOOTSTRAP_NODE_KEY; class BootstrappedPeerFactory { private static final Logger log = LoggerFactory.getLogger(BootstrappedPeerFactory.class); + static final String BOOTSTRAP_NODE_KEY = "bootstrapNode"; + private KeyPair keyPair; private Storage storage; private final Node bootstrapNode; diff --git a/src/main/java/io/bitsquare/msg/tomp2p/TomP2PMessageModule.java b/src/main/java/io/bitsquare/msg/tomp2p/TomP2PMessageModule.java index bf414507fc..461841846e 100644 --- a/src/main/java/io/bitsquare/msg/tomp2p/TomP2PMessageModule.java +++ b/src/main/java/io/bitsquare/msg/tomp2p/TomP2PMessageModule.java @@ -19,11 +19,14 @@ package io.bitsquare.msg.tomp2p; import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageModule; +import io.bitsquare.network.Node; import com.google.inject.name.Names; import java.util.Properties; +import static io.bitsquare.network.BootstrapNodes.DEFAULT_BOOTSTRAP_NODE; + public class TomP2PMessageModule extends MessageModule { public TomP2PMessageModule(Properties properties) { @@ -36,6 +39,17 @@ public class TomP2PMessageModule extends MessageModule { bind(Boolean.class).annotatedWith(Names.named(TomP2PNode.USE_DISK_STORAGE_KEY)).toInstance(false); bind(TomP2PNode.class).asEagerSingleton(); + + Node bootstrapNode = Node.at( + properties.getProperty(BOOTSTRAP_NODE_ID_KEY, DEFAULT_BOOTSTRAP_NODE.getId()), + properties.getProperty(BOOTSTRAP_NODE_IP_KEY, DEFAULT_BOOTSTRAP_NODE.getIp()), + properties.getProperty(BOOTSTRAP_NODE_PORT_KEY, DEFAULT_BOOTSTRAP_NODE.getPortAsString()) + ); + + bind(Node.class) + .annotatedWith(Names.named(BootstrappedPeerFactory.BOOTSTRAP_NODE_KEY)) + .toInstance(bootstrapNode); + bind(BootstrappedPeerFactory.class).asEagerSingleton(); }