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)

View file

@ -126,7 +126,6 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
private Label splashP2PNetworkLabel;
private ProgressBar xmrSyncIndicator;
private Label xmrSplashInfo;
private Popup p2PNetworkWarnMsgPopup, xmrNetworkWarnMsgPopup;
private final TorNetworkSettingsWindow torNetworkSettingsWindow;
private final Preferences preferences;
private static final int networkIconSize = 20;
@ -713,15 +712,10 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
if (newValue != null) {
xmrInfoLabel.setId("splash-error-state-msg");
xmrInfoLabel.getStyleClass().add("error-text");
if (xmrNetworkWarnMsgPopup == null) {
xmrNetworkWarnMsgPopup = new Popup().warning(newValue);
xmrNetworkWarnMsgPopup.show();
}
new Popup().warning(newValue).show();
} else {
xmrInfoLabel.setId("footer-pane");
xmrInfoLabel.getStyleClass().remove("error-text");
if (xmrNetworkWarnMsgPopup != null)
xmrNetworkWarnMsgPopup.hide();
}
});
@ -804,10 +798,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
p2PNetworkLabel.idProperty().bind(model.getP2pNetworkLabelId());
model.getP2pNetworkWarnMsg().addListener((ov, oldValue, newValue) -> {
if (newValue != null) {
p2PNetworkWarnMsgPopup = new Popup().warning(newValue);
p2PNetworkWarnMsgPopup.show();
} else if (p2PNetworkWarnMsgPopup != null) {
p2PNetworkWarnMsgPopup.hide();
new Popup().warning(newValue).show();
}
});
p2PNetworkIcon.setOnMouseClicked(e -> {