mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-18 11:18:36 -04:00
Make regtest default, use random node ports
This commit is contained in:
parent
598db75bfc
commit
22338a8d4d
2 changed files with 24 additions and 2 deletions
|
@ -29,7 +29,7 @@ public enum BitcoinNetwork {
|
||||||
REGTEST(RegTestParams.get());
|
REGTEST(RegTestParams.get());
|
||||||
|
|
||||||
public static final String KEY = "bitcoin.network";
|
public static final String KEY = "bitcoin.network";
|
||||||
public static final BitcoinNetwork DEFAULT = TESTNET;
|
public static final BitcoinNetwork DEFAULT = REGTEST;
|
||||||
|
|
||||||
private final NetworkParameters parameters;
|
private final NetworkParameters parameters;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,16 @@ package io.bitsquare.p2p;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.net.ServerSocket;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public final class Node {
|
public final class Node {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(Node.class);
|
||||||
|
|
||||||
public static final String NAME_KEY = "node.name";
|
public static final String NAME_KEY = "node.name";
|
||||||
public static final String PORT_KEY = "node.port";
|
public static final String PORT_KEY = "node.port";
|
||||||
|
|
||||||
|
@ -28,7 +37,7 @@ public final class Node {
|
||||||
* href="https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?&page=103">
|
* href="https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?&page=103">
|
||||||
* currently unassigned by IANA</a> (7366-7390).
|
* currently unassigned by IANA</a> (7366-7390).
|
||||||
*/
|
*/
|
||||||
public static final int DEFAULT_PORT = 7366;
|
public static int DEFAULT_PORT = findFreeSystemPort();
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String ip;
|
private final String ip;
|
||||||
|
@ -71,6 +80,19 @@ public final class Node {
|
||||||
return Node.at(this.name, this.ip, newPort);
|
return Node.at(this.name, this.ip, newPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int findFreeSystemPort() {
|
||||||
|
int port = 7366;
|
||||||
|
try {
|
||||||
|
ServerSocket server = new ServerSocket(0);
|
||||||
|
port = server.getLocalPort();
|
||||||
|
server.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (this == object)
|
if (this == object)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue