diff --git a/core/src/main/java/haveno/core/api/XmrConnectionService.java b/core/src/main/java/haveno/core/api/XmrConnectionService.java index efd5158d12..8284e01fc8 100644 --- a/core/src/main/java/haveno/core/api/XmrConnectionService.java +++ b/core/src/main/java/haveno/core/api/XmrConnectionService.java @@ -93,7 +93,7 @@ public final class XmrConnectionService { private final MoneroConnectionManager connectionManager; private final EncryptedConnectionList connectionList; private final ObjectProperty> connections = new SimpleObjectProperty<>(); - private final IntegerProperty numConnections = new SimpleIntegerProperty(0); + private final IntegerProperty numConnections = new SimpleIntegerProperty(-1); private final ObjectProperty 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"); diff --git a/core/src/main/java/haveno/core/app/P2PNetworkSetup.java b/core/src/main/java/haveno/core/app/P2PNetworkSetup.java index 69609a4bba..18a26bdb5e 100644 --- a/core/src/main/java/haveno/core/app/P2PNetworkSetup.java +++ b/core/src/main/java/haveno/core/app/P2PNetworkSetup.java @@ -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) diff --git a/desktop/src/main/java/haveno/desktop/main/MainView.java b/desktop/src/main/java/haveno/desktop/main/MainView.java index 99e75b2a69..96bb796e2c 100644 --- a/desktop/src/main/java/haveno/desktop/main/MainView.java +++ b/desktop/src/main/java/haveno/desktop/main/MainView.java @@ -126,7 +126,6 @@ public class MainView extends InitializableView { 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 { 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 { 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 -> {