@@ -93,7 +93,7 @@ public enum XmrConnectionFallbackType {
93
93
private final MoneroConnectionManager connectionManager ;
94
94
private final EncryptedConnectionList connectionList ;
95
95
private final ObjectProperty <List <MoneroRpcConnection >> connections = new SimpleObjectProperty <>();
96
- private final IntegerProperty numConnections = new SimpleIntegerProperty (0 );
96
+ private final IntegerProperty numConnections = new SimpleIntegerProperty (- 1 );
97
97
private final ObjectProperty <MoneroRpcConnection > connectionProperty = new SimpleObjectProperty <>();
98
98
private final LongProperty chainHeight = new SimpleLongProperty (0 );
99
99
private final DownloadListener downloadListener = new DownloadListener ();
@@ -845,6 +845,9 @@ private void doPollMonerod() {
845
845
return ;
846
846
}
847
847
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
+
848
851
// update properties on user thread
849
852
UserThread .execute (() -> {
850
853
@@ -870,12 +873,19 @@ else if (lastInfo.isBusySyncing()) {
870
873
}
871
874
}
872
875
connections .set (availableConnections );
873
- numConnections .set (availableConnections . size () );
876
+ numConnections .set (numOutgoingConnections );
874
877
875
878
// notify update
876
879
numUpdates .set (numUpdates .get () + 1 );
877
880
});
878
881
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
+
879
889
// handle error recovery
880
890
if (lastLogPollErrorTimestamp != null ) {
881
891
log .info ("Successfully fetched monerod info after previous error" );
0 commit comments