Added command line option to set DHTManager seed peer ID

This commit is contained in:
Steve Myers 2014-10-23 20:13:24 -07:00
parent d24e4cfd84
commit afa6af5fd1
2 changed files with 15 additions and 3 deletions

View File

@ -17,6 +17,7 @@
package io.bitsquare;
import io.bitsquare.msg.SeedNodeAddress;
import io.bitsquare.msg.actor.DHTManager;
import io.bitsquare.msg.actor.command.InitializePeer;
import io.bitsquare.msg.actor.event.PeerInitialized;
@ -76,6 +77,11 @@ public class BitSquare {
}
if (namespace.getBoolean(BitsquareArgumentParser.SEED_FLAG) == true) {
String seedID = SeedNodeAddress.StaticSeedNodeAddresses.DIGITAL_OCEAN1.getId();
if (namespace.getString(BitsquareArgumentParser.SEED_ID_FLAG) != null) {
seedID = namespace.getString(BitsquareArgumentParser.SEED_ID_FLAG);
}
Integer port = BitsquareArgumentParser.PORT_DEFAULT;
if (namespace.getString(BitsquareArgumentParser.PORT_FLAG) != null) {
port = Integer.valueOf(namespace.getString(BitsquareArgumentParser.PORT_FLAG));
@ -85,7 +91,7 @@ public class BitSquare {
ActorRef seedNode = actorSystem.actorOf(DHTManager.getProps(), DHTManager.SEED_NAME);
Inbox inbox = Inbox.create(actorSystem);
inbox.send(seedNode, new InitializePeer(Number160.createHash("localhost"), port, interfaceHint, null));
inbox.send(seedNode, new InitializePeer(Number160.createHash(seedID), port, interfaceHint, null));
Thread seedNodeThread = new Thread(() -> {
Boolean quit = false;

View File

@ -17,6 +17,8 @@
package io.bitsquare.util;
import io.bitsquare.msg.SeedNodeAddress;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.impl.Arguments;
import net.sourceforge.argparse4j.inf.ArgumentParser;
@ -26,6 +28,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
public class BitsquareArgumentParser {
public static String SEED_FLAG = "seed";
public static String SEED_ID_FLAG = "seedid";
public static String PORT_FLAG = "port";
public static Integer PORT_DEFAULT = 5000;
public static String INFHINT_FLAG = "interface";
@ -39,11 +42,14 @@ public class BitsquareArgumentParser {
.description("BitSquare decentralized bitcoin exchange.");
parser.addArgument("-s", "--" + SEED_FLAG)
.action(Arguments.storeTrue())
.help("Start in DHT seed mode, no UI.");
.help("Start as DHT seed node, no UI.");
parser.addArgument("-d", "--" + SEED_ID_FLAG)
.setDefault(SeedNodeAddress.StaticSeedNodeAddresses.DIGITAL_OCEAN1.getId())
.help("Seed node peer ID.");
parser.addArgument("-p", "--"+PORT_FLAG)
.setDefault(PORT_DEFAULT)
.help("IP port to listen on.");
parser.addArgument("-i", "--"+INFHINT_FLAG)
parser.addArgument("-i", "--" + INFHINT_FLAG)
.help("interface to listen on.");
parser.addArgument("-n", "--"+NAME_FLAG)
.help("Append name to application name.");