Skip to content

Commit 4e297b5

Browse files
committed
show error popup when monerod has 0 peers (unrestricted only)
1 parent 62ece93 commit 4e297b5

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

core/src/main/java/haveno/core/api/XmrConnectionService.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public enum XmrConnectionFallbackType {
9393
private final MoneroConnectionManager connectionManager;
9494
private final EncryptedConnectionList connectionList;
9595
private final ObjectProperty<List<MoneroRpcConnection>> connections = new SimpleObjectProperty<>();
96-
private final IntegerProperty numConnections = new SimpleIntegerProperty(0);
96+
private final IntegerProperty numConnections = new SimpleIntegerProperty(-1);
9797
private final ObjectProperty<MoneroRpcConnection> connectionProperty = new SimpleObjectProperty<>();
9898
private final LongProperty chainHeight = new SimpleLongProperty(0);
9999
private final DownloadListener downloadListener = new DownloadListener();
@@ -845,6 +845,12 @@ private void doPollMonerod() {
845845
return;
846846
}
847847

848+
// set the number of connections which is only availale if not restricted
849+
numConnections.set(Boolean.TRUE.equals(lastInfo.isRestricted()) ? -1 : lastInfo.getNumOutgoingConnections());
850+
if (numConnections.get() == 0) {
851+
throw new RuntimeException("The Monero node has no connected peers. It may be experiencing a network connectivity issue.");
852+
}
853+
848854
// update properties on user thread
849855
UserThread.execute(() -> {
850856

@@ -870,7 +876,6 @@ else if (lastInfo.isBusySyncing()) {
870876
}
871877
}
872878
connections.set(availableConnections);
873-
numConnections.set(availableConnections.size());
874879

875880
// notify update
876881
numUpdates.set(numUpdates.get() + 1);

core/src/main/java/haveno/core/app/P2PNetworkSetup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ BooleanProperty init(Runnable onReadyHandler, @Nullable Consumer<Boolean> displa
9494
if (warning != null && p2pPeers == 0) {
9595
result = warning;
9696
} else {
97-
String p2pInfo = ((int) numXmrPeers > 0 ? Res.get("mainView.footer.xmrPeers", numXmrPeers) + " / " : "") + Res.get("mainView.footer.p2pPeers", numP2pPeers);
97+
String p2pInfo = ((int) numXmrPeers >= 0 ? Res.get("mainView.footer.xmrPeers", numXmrPeers) + " / " : "") + Res.get("mainView.footer.p2pPeers", numP2pPeers);
9898
if (dataReceived && hiddenService) {
9999
result = p2pInfo;
100100
} else if (p2pPeers == 0)

desktop/src/main/java/haveno/desktop/main/MainView.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,10 +713,9 @@ private AnchorPane createFooter() {
713713
if (newValue != null) {
714714
xmrInfoLabel.setId("splash-error-state-msg");
715715
xmrInfoLabel.getStyleClass().add("error-text");
716-
if (xmrNetworkWarnMsgPopup == null) {
717-
xmrNetworkWarnMsgPopup = new Popup().warning(newValue);
718-
xmrNetworkWarnMsgPopup.show();
719-
}
716+
if (xmrNetworkWarnMsgPopup == null)
717+
xmrNetworkWarnMsgPopup = new Popup();
718+
xmrNetworkWarnMsgPopup.warning(newValue).show();
720719
} else {
721720
xmrInfoLabel.setId("footer-pane");
722721
xmrInfoLabel.getStyleClass().remove("error-text");

0 commit comments

Comments
 (0)