mirror of
https://github.com/boldsuck/haveno.git
synced 2025-01-31 03:05:52 +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() {
|
||||
accountService.checkAccountOpen();
|
||||
return getBestConnection(new ArrayList<MoneroRpcConnection>());
|
||||
}
|
||||
|
||||
|
@ -264,8 +263,9 @@ public final class XmrConnectionService {
|
|||
accountService.checkAccountOpen();
|
||||
Set<MoneroRpcConnection> ignoredConnectionsSet = new HashSet<>(ignoredConnections);
|
||||
addLocalNodeIfIgnored(ignoredConnectionsSet);
|
||||
if (connectionManager.getConnections().size() == 1 && !ignoredConnectionsSet.contains(connectionManager.getConnections().get(0))) return connectionManager.getConnections().get(0);
|
||||
return connectionManager.getBestAvailableConnection(ignoredConnectionsSet.toArray(new MoneroRpcConnection[0]));
|
||||
MoneroRpcConnection bestConnection = connectionManager.getBestAvailableConnection(ignoredConnectionsSet.toArray(new MoneroRpcConnection[0])); // checks connections
|
||||
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) {
|
||||
|
@ -336,7 +336,7 @@ public final class XmrConnectionService {
|
|||
}, EXCLUDE_CONNECTION_SECONDS);
|
||||
|
||||
// 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");
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue