mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-27 08:10:45 -04:00
Eliminate BootstrapNodes#DIGITAL_OCEAN_1_DEV
Instead of including testing-related bootstrap nodes in the BootstrapNodes class, this change introduces a Node#withPort method that allows for obtaining a copy of an existing bootstrap node (e.g. DIGITAL_OCEAN_1) with a modified port value. This approach to `with*` methods allows for convenient customization of value types without sacrificing immutability. See [1] for details. [1]: http://blog.joda.org/2014/03/valjos-value-java-objects.html
This commit is contained in:
parent
5ab837658b
commit
adfd8b2ac4
3 changed files with 8 additions and 2 deletions
|
@ -23,7 +23,6 @@ import java.util.List;
|
||||||
public interface BootstrapNodes {
|
public interface BootstrapNodes {
|
||||||
|
|
||||||
Node DIGITAL_OCEAN_1 = Node.at("digitalocean1.bitsquare.io", "188.226.179.109");
|
Node DIGITAL_OCEAN_1 = Node.at("digitalocean1.bitsquare.io", "188.226.179.109");
|
||||||
Node DIGITAL_OCEAN_1_DEV = Node.at("digitalocean1.bitsquare.io", "188.226.179.109", 7367);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias to the default bootstrap node.
|
* Alias to the default bootstrap node.
|
||||||
|
|
|
@ -68,6 +68,13 @@ public final class Node {
|
||||||
return String.valueOf(port);
|
return String.valueOf(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a copy of this node with the port updated to the given value.
|
||||||
|
*/
|
||||||
|
public Node withPort(int newPort) {
|
||||||
|
return Node.at(this.name, this.ip, newPort);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (this == object)
|
if (this == object)
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class TomP2PTests {
|
||||||
// Typically you run the bootstrap node on localhost to test direct connection.
|
// Typically you run the bootstrap node on localhost to test direct connection.
|
||||||
// If you have a setup where you are not behind a router you can also use a WAN bootstrap node.
|
// If you have a setup where you are not behind a router you can also use a WAN bootstrap node.
|
||||||
private static final Node BOOTSTRAP_NODE = (FORCED_CONNECTION_TYPE == ConnectionType.DIRECT) ?
|
private static final Node BOOTSTRAP_NODE = (FORCED_CONNECTION_TYPE == ConnectionType.DIRECT) ?
|
||||||
BootstrapNodes.LOCALHOST : BootstrapNodes.DIGITAL_OCEAN_1_DEV;
|
BootstrapNodes.LOCALHOST : BootstrapNodes.DIGITAL_OCEAN_1.withPort(7367);
|
||||||
|
|
||||||
private static final PeerAddress BOOTSTRAP_NODE_ADDRESS;
|
private static final PeerAddress BOOTSTRAP_NODE_ADDRESS;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue