show error popup when unrestricted monerod has 0 peers

This commit is contained in:
woodser 2025-07-20 10:29:16 -04:00 committed by woodser
parent f4d2646cf3
commit 9f55c5d648
3 changed files with 15 additions and 14 deletions

View file

@ -93,7 +93,7 @@ public final class XmrConnectionService {
private final MoneroConnectionManager connectionManager;
private final EncryptedConnectionList connectionList;
private final ObjectProperty<List<MoneroRpcConnection>> connections = new SimpleObjectProperty<>();
private final IntegerProperty numConnections = new SimpleIntegerProperty(0);
private final IntegerProperty numConnections = new SimpleIntegerProperty(-1);
private final ObjectProperty<MoneroRpcConnection> connectionProperty = new SimpleObjectProperty<>();
private final LongProperty chainHeight = new SimpleLongProperty(0);
private final DownloadListener downloadListener = new DownloadListener();
@ -845,6 +845,9 @@ public final class XmrConnectionService {
return;
}
// get the number of connections, which is only available if not restricted
int numOutgoingConnections = Boolean.TRUE.equals(lastInfo.isRestricted()) ? -1 : lastInfo.getNumOutgoingConnections();
// update properties on user thread
UserThread.execute(() -> {
@ -870,12 +873,19 @@ public final class XmrConnectionService {
}
}
connections.set(availableConnections);
numConnections.set(availableConnections.size());
numConnections.set(numOutgoingConnections);
// notify update
numUpdates.set(numUpdates.get() + 1);
});
// invoke error handling if no connections
if (numOutgoingConnections == 0) {
String errorMsg = "The Monero node has no connected peers. It may be experiencing a network connectivity issue.";
log.warn(errorMsg);
throw new RuntimeException(errorMsg);
}
// handle error recovery
if (lastLogPollErrorTimestamp != null) {
log.info("Successfully fetched monerod info after previous error");

View file

@ -94,7 +94,7 @@ public class P2PNetworkSetup {
if (warning != null && p2pPeers == 0) {
result = warning;
} else {
String p2pInfo = ((int) numXmrPeers > 0 ? Res.get("mainView.footer.xmrPeers", numXmrPeers) + " / " : "") + Res.get("mainView.footer.p2pPeers", numP2pPeers);
String p2pInfo = ((int) numXmrPeers >= 0 ? Res.get("mainView.footer.xmrPeers", numXmrPeers) + " / " : "") + Res.get("mainView.footer.p2pPeers", numP2pPeers);
if (dataReceived && hiddenService) {
result = p2pInfo;
} else if (p2pPeers == 0)