diff --git a/src/main/java/io/bitsquare/app/cli/SeedNode.java b/src/main/java/io/bitsquare/app/cli/SeedNode.java index 3708813289..1b3d847b3a 100644 --- a/src/main/java/io/bitsquare/app/cli/SeedNode.java +++ b/src/main/java/io/bitsquare/app/cli/SeedNode.java @@ -62,7 +62,7 @@ public class SeedNode { } final Set peerAddresses = new HashSet<>(); - for (Node node : BootstrapNode.values()) { + for (Node node : BootstrapNode.all()) { if (!node.getId().equals(seedID)) { try { peerAddresses.add(new PeerAddress(Number160.createHash(node.getId()), node.getIp(), diff --git a/src/main/java/io/bitsquare/network/BootstrapNode.java b/src/main/java/io/bitsquare/network/BootstrapNode.java index c4d37427b7..e59d57ba49 100644 --- a/src/main/java/io/bitsquare/network/BootstrapNode.java +++ b/src/main/java/io/bitsquare/network/BootstrapNode.java @@ -17,28 +17,16 @@ package io.bitsquare.network; -public enum BootstrapNode implements Node { - LOCALHOST(Node.at("localhost", "127.0.0.1")), - DIGITAL_OCEAN1(Node.at("digitalocean1.bitsquare.io", "188.226.179.109")); +import java.util.Arrays; +import java.util.List; - private final Node self; +public interface BootstrapNode { + Node LOCALHOST = Node.at("localhost", "127.0.0.1"); + Node DIGITAL_OCEAN1 = Node.at("digitalocean1.bitsquare.io", "188.226.179.109"); - BootstrapNode(Node self) { - this.self = self; - } - - @Override - public String getId() { - return self.getId(); - } - - @Override - public String getIp() { - return self.getIp(); - } - - @Override - public int getPort() { - return self.getPort(); + static List all() { + return Arrays.asList( + LOCALHOST, DIGITAL_OCEAN1 + ); } } diff --git a/src/main/java/io/bitsquare/network/Node.java b/src/main/java/io/bitsquare/network/Node.java index 97e1953d9c..b975851ca6 100644 --- a/src/main/java/io/bitsquare/network/Node.java +++ b/src/main/java/io/bitsquare/network/Node.java @@ -17,21 +17,66 @@ package io.bitsquare.network; -public interface Node { +import com.google.common.base.Objects; +public final class Node { public static final int DEFAULT_PORT = 5000; - String getId(); + private final String id; + private final String ip; + private final int port; - String getIp(); + private Node(String id, String ip, int port) { + this.id = id; + this.ip = ip; + this.port = port; + } - int getPort(); - - static Node at(String id, String ip) { + public static Node at(String id, String ip) { return Node.at(id, ip, DEFAULT_PORT); } - static Node at(String id, String ip, int port) { - return new NodeImpl(id, ip, port); + public static Node at(String id, String ip, int port) { + return new Node(id, ip, port); + } + + public String getId() { + return id; + } + + public String getIp() { + return ip; + } + + public int getPort() { + return port; + } + + @Override + public boolean equals(Object object) { + if (this == object) + return true; + + if (object == null || getClass() != object.getClass()) + return false; + + Node that = (Node) object; + return Objects.equal(this.id, that.id) && + Objects.equal(this.ip, that.ip) && + Objects.equal(this.port, that.port); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, ip, port); + } + + @Override + public String toString() { + return Objects.toStringHelper(Node.class.getSimpleName()) + .add("id", id) + .add("ip", ip) + .add("port", port) + .toString(); } } diff --git a/src/main/java/io/bitsquare/network/NodeImpl.java b/src/main/java/io/bitsquare/network/NodeImpl.java deleted file mode 100644 index b98824d271..0000000000 --- a/src/main/java/io/bitsquare/network/NodeImpl.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of Bitsquare. - * - * Bitsquare is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bitsquare is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bitsquare. If not, see . - */ - -package io.bitsquare.network; - -import com.google.common.base.Objects; - -final class NodeImpl implements Node { - - private final String id; - private final String ip; - private final int port; - - NodeImpl(String id, String ip, int port) { - this.id = id; - this.ip = ip; - this.port = port; - } - - @Override - public String getId() { - return id; - } - - @Override - public String getIp() { - return ip; - } - - @Override - public int getPort() { - return port; - } - - @Override - public boolean equals(Object object) { - if (this == object) - return true; - - if (object == null || getClass() != object.getClass()) - return false; - - NodeImpl that = (NodeImpl) object; - return Objects.equal(this.id, that.id) && - Objects.equal(this.ip, that.ip) && - Objects.equal(this.port, that.port); - } - - @Override - public int hashCode() { - return Objects.hashCode(id, ip, port); - } - - @Override - public String toString() { - return Objects.toStringHelper(Node.class.getSimpleName()) - .add("id", id) - .add("ip", ip) - .add("port", port) - .toString(); - } -}