Skip to content

Commit ba2a742

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

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

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

Lines changed: 12 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,9 @@ private void doPollMonerod() {
845845
return;
846846
}
847847

848+
// get the number of connections, which is only available if not restricted
849+
int numOutgoingConnections = Boolean.TRUE.equals(lastInfo.isRestricted()) ? -1 : lastInfo.getNumOutgoingConnections();
850+
848851
// update properties on user thread
849852
UserThread.execute(() -> {
850853

@@ -870,12 +873,19 @@ else if (lastInfo.isBusySyncing()) {
870873
}
871874
}
872875
connections.set(availableConnections);
873-
numConnections.set(availableConnections.size());
876+
numConnections.set(numOutgoingConnections);
874877

875878
// notify update
876879
numUpdates.set(numUpdates.get() + 1);
877880
});
878881

882+
// invoke error handling if no connections
883+
if (numOutgoingConnections == 0) {
884+
String errorMsg = "The Monero node has no connected peers. It may be experiencing a network connectivity issue.";
885+
log.warn(errorMsg);
886+
throw new RuntimeException(errorMsg);
887+
}
888+
879889
// handle error recovery
880890
if (lastLogPollErrorTimestamp != null) {
881891
log.info("Successfully fetched monerod info after previous error");

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)