do not check best connection when connection is fixed

This commit is contained in:
woodser 2024-01-12 07:45:21 -05:00
parent 5c28428436
commit bcb951ca40

View File

@ -480,8 +480,9 @@ public final class XmrConnectionService {
maybeStartLocalNode(); maybeStartLocalNode();
// update connection // update connection
if (connectionManager.getConnection() == null || connectionManager.getAutoSwitch()) { if (!isFixedConnection() && (connectionManager.getConnection() == null || connectionManager.getAutoSwitch())) {
setConnection(getBestAvailableConnection()); MoneroRpcConnection bestConnection = getBestAvailableConnection();
if (bestConnection != null) setConnection(bestConnection);
} else { } else {
checkConnection(); checkConnection();
} }
@ -503,12 +504,10 @@ public final class XmrConnectionService {
// register connection listener // register connection listener
connectionManager.addListener(this::onConnectionChanged); connectionManager.addListener(this::onConnectionChanged);
// start polling for best connection after delay // start polling after delay
if ("".equals(config.xmrNode)) { UserThread.runAfter(() -> {
UserThread.runAfter(() -> { if (!isShutDownStarted) connectionManager.startPolling(getRefreshPeriodMs() * 2);
if (!isShutDownStarted) connectionManager.startPolling(getRefreshPeriodMs() * 2); }, getDefaultRefreshPeriodMs() * 2 / 1000);
}, getDefaultRefreshPeriodMs() * 2 / 1000);
}
isInitialized = true; isInitialized = true;
} }
@ -666,7 +665,7 @@ public final class XmrConnectionService {
} }
new Thread(() -> { new Thread(() -> {
if (connectionManager.getAutoSwitch()) { if (!isFixedConnection() && connectionManager.getAutoSwitch()) {
MoneroRpcConnection bestConnection = getBestAvailableConnection(); MoneroRpcConnection bestConnection = getBestAvailableConnection();
if (bestConnection != null) connectionManager.setConnection(bestConnection); if (bestConnection != null) connectionManager.setConnection(bestConnection);
} else { } else {
@ -689,4 +688,8 @@ public final class XmrConnectionService {
.filter(peer -> peer.isOnline()) .filter(peer -> peer.isOnline())
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private boolean isFixedConnection() {
return !"".equals(config.xmrNode) || preferences.getMoneroNodesOption() == XmrNodes.MoneroNodesOption.CUSTOM;
}
} }