mirror of
https://github.com/boldsuck/haveno.git
synced 2025-02-28 05:40:18 +00:00
check for best connection before returning singular connection
This commit is contained in:
parent
e1b3cdce28
commit
69da858365
1 changed files with 4 additions and 4 deletions
|
@ -256,7 +256,6 @@ public final class XmrConnectionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MoneroRpcConnection getBestConnection() {
|
public MoneroRpcConnection getBestConnection() {
|
||||||
accountService.checkAccountOpen();
|
|
||||||
return getBestConnection(new ArrayList<MoneroRpcConnection>());
|
return getBestConnection(new ArrayList<MoneroRpcConnection>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,8 +263,9 @@ public final class XmrConnectionService {
|
||||||
accountService.checkAccountOpen();
|
accountService.checkAccountOpen();
|
||||||
Set<MoneroRpcConnection> ignoredConnectionsSet = new HashSet<>(ignoredConnections);
|
Set<MoneroRpcConnection> ignoredConnectionsSet = new HashSet<>(ignoredConnections);
|
||||||
addLocalNodeIfIgnored(ignoredConnectionsSet);
|
addLocalNodeIfIgnored(ignoredConnectionsSet);
|
||||||
if (connectionManager.getConnections().size() == 1 && !ignoredConnectionsSet.contains(connectionManager.getConnections().get(0))) return connectionManager.getConnections().get(0);
|
MoneroRpcConnection bestConnection = connectionManager.getBestAvailableConnection(ignoredConnectionsSet.toArray(new MoneroRpcConnection[0])); // checks connections
|
||||||
return connectionManager.getBestAvailableConnection(ignoredConnectionsSet.toArray(new MoneroRpcConnection[0]));
|
if (bestConnection == null && connectionManager.getConnections().size() == 1 && !ignoredConnectionsSet.contains(connectionManager.getConnections().get(0))) bestConnection = connectionManager.getConnections().get(0);
|
||||||
|
return bestConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addLocalNodeIfIgnored(Collection<MoneroRpcConnection> ignoredConnections) {
|
private void addLocalNodeIfIgnored(Collection<MoneroRpcConnection> ignoredConnections) {
|
||||||
|
@ -336,7 +336,7 @@ public final class XmrConnectionService {
|
||||||
}, EXCLUDE_CONNECTION_SECONDS);
|
}, EXCLUDE_CONNECTION_SECONDS);
|
||||||
|
|
||||||
// return if no connection to switch to
|
// return if no connection to switch to
|
||||||
if (bestConnection == null) {
|
if (bestConnection == null || !Boolean.TRUE.equals(bestConnection.isConnected())) {
|
||||||
log.warn("No connection to switch to");
|
log.warn("No connection to switch to");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue