mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-30 18:28:52 -04:00
Move {MessageModule=>BootstrappedPeerFactory}#BOOTSTRAP_NODE_KEY
This commit is contained in:
parent
426ee28b93
commit
9bdb4b4249
3 changed files with 17 additions and 16 deletions
|
@ -18,15 +18,12 @@
|
||||||
package io.bitsquare.msg;
|
package io.bitsquare.msg;
|
||||||
|
|
||||||
import io.bitsquare.BitsquareModule;
|
import io.bitsquare.BitsquareModule;
|
||||||
import io.bitsquare.network.Node;
|
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.name.Names;
|
import com.google.inject.name.Names;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import static io.bitsquare.network.BootstrapNodes.DEFAULT_BOOTSTRAP_NODE;
|
|
||||||
|
|
||||||
public abstract class MessageModule extends BitsquareModule {
|
public abstract class MessageModule extends BitsquareModule {
|
||||||
|
|
||||||
public static final String BOOTSTRAP_NODE_ID_KEY = "id";
|
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 BOOTSTRAP_NODE_PORT_KEY = "port";
|
||||||
public static final String NETWORK_INTERFACE_KEY = "networkInterface";
|
public static final String NETWORK_INTERFACE_KEY = "networkInterface";
|
||||||
|
|
||||||
public static final String BOOTSTRAP_NODE_KEY = "bootstrapNode";
|
|
||||||
|
|
||||||
protected MessageModule(Properties properties) {
|
protected MessageModule(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
@ -44,16 +39,6 @@ public abstract class MessageModule extends BitsquareModule {
|
||||||
protected final void configure() {
|
protected final void configure() {
|
||||||
bind(MessageFacade.class).to(messageFacade()).asEagerSingleton();
|
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)
|
bind(String.class)
|
||||||
.annotatedWith(Names.named("networkInterface"))
|
.annotatedWith(Names.named("networkInterface"))
|
||||||
.toInstance(properties.getProperty(NETWORK_INTERFACE_KEY, ""));
|
.toInstance(properties.getProperty(NETWORK_INTERFACE_KEY, ""));
|
||||||
|
|
|
@ -68,7 +68,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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
|
* 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 {
|
class BootstrappedPeerFactory {
|
||||||
private static final Logger log = LoggerFactory.getLogger(BootstrappedPeerFactory.class);
|
private static final Logger log = LoggerFactory.getLogger(BootstrappedPeerFactory.class);
|
||||||
|
|
||||||
|
static final String BOOTSTRAP_NODE_KEY = "bootstrapNode";
|
||||||
|
|
||||||
private KeyPair keyPair;
|
private KeyPair keyPair;
|
||||||
private Storage storage;
|
private Storage storage;
|
||||||
private final Node bootstrapNode;
|
private final Node bootstrapNode;
|
||||||
|
|
|
@ -19,11 +19,14 @@ package io.bitsquare.msg.tomp2p;
|
||||||
|
|
||||||
import io.bitsquare.msg.MessageFacade;
|
import io.bitsquare.msg.MessageFacade;
|
||||||
import io.bitsquare.msg.MessageModule;
|
import io.bitsquare.msg.MessageModule;
|
||||||
|
import io.bitsquare.network.Node;
|
||||||
|
|
||||||
import com.google.inject.name.Names;
|
import com.google.inject.name.Names;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static io.bitsquare.network.BootstrapNodes.DEFAULT_BOOTSTRAP_NODE;
|
||||||
|
|
||||||
public class TomP2PMessageModule extends MessageModule {
|
public class TomP2PMessageModule extends MessageModule {
|
||||||
|
|
||||||
public TomP2PMessageModule(Properties properties) {
|
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(Boolean.class).annotatedWith(Names.named(TomP2PNode.USE_DISK_STORAGE_KEY)).toInstance(false);
|
||||||
|
|
||||||
bind(TomP2PNode.class).asEagerSingleton();
|
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();
|
bind(BootstrappedPeerFactory.class).asEagerSingleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue