mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 19:49:32 +00:00
fix wallet rpc initialization
This commit is contained in:
parent
2dc5481101
commit
3ba106d466
1 changed files with 4 additions and 6 deletions
|
@ -67,16 +67,16 @@ public class MoneroWalletRpcManager {
|
||||||
else {
|
else {
|
||||||
int numAttempts = 0;
|
int numAttempts = 0;
|
||||||
while (numAttempts < NUM_ALLOWED_ATTEMPTS) {
|
while (numAttempts < NUM_ALLOWED_ATTEMPTS) {
|
||||||
int port = -1;
|
int port;
|
||||||
ServerSocket socket = null;
|
|
||||||
try {
|
try {
|
||||||
numAttempts++;
|
numAttempts++;
|
||||||
|
|
||||||
// get port
|
// get port
|
||||||
if (startPort != null) port = registerNextPort();
|
if (startPort != null) port = registerNextPort();
|
||||||
else {
|
else {
|
||||||
socket = new ServerSocket(0);
|
ServerSocket socket = new ServerSocket(0);
|
||||||
port = socket.getLocalPort();
|
port = socket.getLocalPort();
|
||||||
|
socket.close();
|
||||||
synchronized (registeredPorts) {
|
synchronized (registeredPorts) {
|
||||||
registeredPorts.put(port, null);
|
registeredPorts.put(port, null);
|
||||||
}
|
}
|
||||||
|
@ -96,8 +96,6 @@ public class MoneroWalletRpcManager {
|
||||||
log.error("Unable to start monero-wallet-rpc instance after {} attempts", NUM_ALLOWED_ATTEMPTS);
|
log.error("Unable to start monero-wallet-rpc instance after {} attempts", NUM_ALLOWED_ATTEMPTS);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
if (socket != null) socket.close(); // close socket if used
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new MoneroError("Failed to start monero-wallet-rpc instance after " + NUM_ALLOWED_ATTEMPTS + " attempts"); // should never reach here
|
throw new MoneroError("Failed to start monero-wallet-rpc instance after " + NUM_ALLOWED_ATTEMPTS + " attempts"); // should never reach here
|
||||||
|
@ -143,7 +141,7 @@ public class MoneroWalletRpcManager {
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unregisterPort(int port) {
|
private void unregisterPort(int port) {
|
||||||
synchronized (registeredPorts) {
|
synchronized (registeredPorts) {
|
||||||
registeredPorts.remove(port);
|
registeredPorts.remove(port);
|
||||||
|
|
Loading…
Reference in a new issue