mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 23:36:00 -04:00
Move bootstrap node config property keys to MessageModule
This commit is contained in:
parent
20db54e87b
commit
18c399b30c
@ -21,11 +21,10 @@ import net.sourceforge.argparse4j.ArgumentParsers;
|
||||
import net.sourceforge.argparse4j.inf.ArgumentParserException;
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
|
||||
import static io.bitsquare.msg.MessageModule.*;
|
||||
|
||||
public class ArgumentParser {
|
||||
|
||||
public static final String SEED_ID_FLAG = "id";
|
||||
public static final String SEED_IP_FLAG = "ip";
|
||||
public static final String SEED_PORT_FLAG = "port";
|
||||
public static final String NAME_FLAG = "name";
|
||||
|
||||
private final net.sourceforge.argparse4j.inf.ArgumentParser parser;
|
||||
@ -36,11 +35,11 @@ public class ArgumentParser {
|
||||
.description("Bitsquare - The decentralized bitcoin exchange");
|
||||
|
||||
// Args for seed node config
|
||||
parser.addArgument("-d", "--" + SEED_ID_FLAG)
|
||||
parser.addArgument("-d", "--" + BOOTSTRAP_NODE_ID_KEY)
|
||||
.help("Seed node ID");
|
||||
parser.addArgument("-s", "--" + SEED_IP_FLAG)
|
||||
parser.addArgument("-s", "--" + BOOTSTRAP_NODE_IP_KEY)
|
||||
.help("Seed node IP");
|
||||
parser.addArgument("-p", "--" + SEED_PORT_FLAG)
|
||||
parser.addArgument("-p", "--" + BOOTSTRAP_NODE_PORT_KEY)
|
||||
.help("Seed node port");
|
||||
|
||||
// Args for app config
|
||||
|
@ -36,6 +36,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
|
||||
import static io.bitsquare.msg.MessageModule.*;
|
||||
|
||||
public class SeedNode {
|
||||
private static final Logger log = LoggerFactory.getLogger(SeedNode.class);
|
||||
|
||||
@ -53,11 +55,11 @@ public class SeedNode {
|
||||
// Passed program args will override the properties of the default bootstrapNode
|
||||
// So you can use the same id but different ports (e.g. running several nodes on one server with
|
||||
// different ports)
|
||||
if (namespace.getString(ArgumentParser.SEED_ID_FLAG) != null)
|
||||
id = namespace.getString(ArgumentParser.SEED_ID_FLAG);
|
||||
if (namespace.getString(BOOTSTRAP_NODE_ID_KEY) != null)
|
||||
id = namespace.getString(BOOTSTRAP_NODE_ID_KEY);
|
||||
|
||||
if (namespace.getString(ArgumentParser.SEED_PORT_FLAG) != null)
|
||||
port = Integer.valueOf(namespace.getString(ArgumentParser.SEED_PORT_FLAG));
|
||||
if (namespace.getString(BOOTSTRAP_NODE_PORT_KEY) != null)
|
||||
port = Integer.valueOf(namespace.getString(BOOTSTRAP_NODE_PORT_KEY));
|
||||
|
||||
try {
|
||||
Number160 peerId = Number160.createHash(id);
|
||||
|
@ -49,7 +49,8 @@ import org.slf4j.LoggerFactory;
|
||||
import lighthouse.files.AppDirectory;
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
|
||||
import static io.bitsquare.app.ArgumentParser.*;
|
||||
import static io.bitsquare.app.ArgumentParser.NAME_FLAG;
|
||||
import static io.bitsquare.msg.MessageModule.*;
|
||||
|
||||
public class Main extends Application {
|
||||
private static final Logger log = LoggerFactory.getLogger(Main.class);
|
||||
@ -69,14 +70,14 @@ public class Main extends Application {
|
||||
|
||||
properties.setProperty(NAME_FLAG, appName);
|
||||
|
||||
if (argumentsNamespace.getString(SEED_ID_FLAG) != null)
|
||||
properties.setProperty(SEED_ID_FLAG, argumentsNamespace.getString(SEED_ID_FLAG));
|
||||
if (argumentsNamespace.getString(BOOTSTRAP_NODE_ID_KEY) != null)
|
||||
properties.setProperty(BOOTSTRAP_NODE_ID_KEY, argumentsNamespace.getString(BOOTSTRAP_NODE_ID_KEY));
|
||||
|
||||
if (argumentsNamespace.getString(SEED_IP_FLAG) != null)
|
||||
properties.setProperty(SEED_IP_FLAG, argumentsNamespace.getString(SEED_IP_FLAG));
|
||||
if (argumentsNamespace.getString(BOOTSTRAP_NODE_IP_KEY) != null)
|
||||
properties.setProperty(BOOTSTRAP_NODE_IP_KEY, argumentsNamespace.getString(BOOTSTRAP_NODE_IP_KEY));
|
||||
|
||||
if (argumentsNamespace.getString(SEED_PORT_FLAG) != null)
|
||||
properties.setProperty(SEED_PORT_FLAG, argumentsNamespace.getString(SEED_PORT_FLAG));
|
||||
if (argumentsNamespace.getString(BOOTSTRAP_NODE_PORT_KEY) != null)
|
||||
properties.setProperty(BOOTSTRAP_NODE_PORT_KEY, argumentsNamespace.getString(BOOTSTRAP_NODE_PORT_KEY));
|
||||
|
||||
Application.launch(Main.class, args);
|
||||
}
|
||||
|
@ -25,11 +25,14 @@ import com.google.inject.name.Names;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import static io.bitsquare.app.ArgumentParser.*;
|
||||
import static io.bitsquare.network.BootstrapNodes.DEFAULT_BOOTSTRAP_NODE;
|
||||
|
||||
public abstract class MessageModule extends BitsquareModule {
|
||||
|
||||
public static final String BOOTSTRAP_NODE_ID_KEY = "id";
|
||||
public static final String BOOTSTRAP_NODE_IP_KEY = "ip";
|
||||
public static final String BOOTSTRAP_NODE_PORT_KEY = "port";
|
||||
|
||||
protected MessageModule(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
@ -42,9 +45,9 @@ public abstract class MessageModule extends BitsquareModule {
|
||||
bind(Boolean.class).annotatedWith(Names.named("useDiskStorage")).toInstance(false);
|
||||
|
||||
Node bootstrapNode = Node.at(
|
||||
properties.getProperty(SEED_ID_FLAG, DEFAULT_BOOTSTRAP_NODE.getId()),
|
||||
properties.getProperty(SEED_IP_FLAG, DEFAULT_BOOTSTRAP_NODE.getIp()),
|
||||
properties.getProperty(SEED_PORT_FLAG, DEFAULT_BOOTSTRAP_NODE.getPortAsString())
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user