mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-27 08:55:22 -04:00
show available monero nodes in network settings
This commit is contained in:
parent
1f385328de
commit
dc8d854709
22 changed files with 100 additions and 95 deletions
|
@ -40,7 +40,6 @@ import java.util.Collection;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
||||
|
@ -64,7 +63,6 @@ import monero.common.MoneroRpcConnection;
|
|||
import monero.common.TaskLooper;
|
||||
import monero.daemon.MoneroDaemonRpc;
|
||||
import monero.daemon.model.MoneroDaemonInfo;
|
||||
import monero.daemon.model.MoneroPeer;
|
||||
|
||||
@Slf4j
|
||||
@Singleton
|
||||
|
@ -85,9 +83,9 @@ public final class XmrConnectionService {
|
|||
private final XmrLocalNode xmrLocalNode;
|
||||
private final MoneroConnectionManager connectionManager;
|
||||
private final EncryptedConnectionList connectionList;
|
||||
private final ObjectProperty<List<MoneroPeer>> peers = new SimpleObjectProperty<>();
|
||||
private final ObjectProperty<List<MoneroRpcConnection>> connections = new SimpleObjectProperty<>();
|
||||
private final IntegerProperty numConnections = new SimpleIntegerProperty(0);
|
||||
private final ObjectProperty<MoneroRpcConnection> connectionProperty = new SimpleObjectProperty<>();
|
||||
private final IntegerProperty numPeers = new SimpleIntegerProperty(0);
|
||||
private final LongProperty chainHeight = new SimpleLongProperty(0);
|
||||
private final DownloadListener downloadListener = new DownloadListener();
|
||||
@Getter
|
||||
|
@ -390,12 +388,12 @@ public final class XmrConnectionService {
|
|||
|
||||
// ----------------------------- APP METHODS ------------------------------
|
||||
|
||||
public ReadOnlyIntegerProperty numPeersProperty() {
|
||||
return numPeers;
|
||||
public ReadOnlyIntegerProperty numConnectionsProperty() {
|
||||
return numConnections;
|
||||
}
|
||||
|
||||
public ReadOnlyObjectProperty<List<MoneroPeer>> peerConnectionsProperty() {
|
||||
return peers;
|
||||
public ReadOnlyObjectProperty<List<MoneroRpcConnection>> connectionsProperty() {
|
||||
return connections;
|
||||
}
|
||||
|
||||
public ReadOnlyObjectProperty<MoneroRpcConnection> connectionProperty() {
|
||||
|
@ -403,7 +401,7 @@ public final class XmrConnectionService {
|
|||
}
|
||||
|
||||
public boolean hasSufficientPeersForBroadcast() {
|
||||
return numPeers.get() >= getMinBroadcastConnections();
|
||||
return numConnections.get() >= getMinBroadcastConnections();
|
||||
}
|
||||
|
||||
public LongProperty chainHeightProperty() {
|
||||
|
@ -782,16 +780,15 @@ public final class XmrConnectionService {
|
|||
downloadListener.progress(percent, blocksLeft, null);
|
||||
}
|
||||
|
||||
// set peer connections
|
||||
// TODO: peers often uknown due to restricted RPC call, skipping call to get peer connections
|
||||
// try {
|
||||
// peers.set(getOnlinePeers());
|
||||
// } catch (Exception err) {
|
||||
// // TODO: peers unknown due to restricted RPC call
|
||||
// }
|
||||
// numPeers.set(peers.get().size());
|
||||
numPeers.set(lastInfo.getNumOutgoingConnections() + lastInfo.getNumIncomingConnections());
|
||||
peers.set(new ArrayList<MoneroPeer>());
|
||||
// set available connections
|
||||
List<MoneroRpcConnection> availableConnections = new ArrayList<>();
|
||||
for (MoneroRpcConnection connection : connectionManager.getConnections()) {
|
||||
if (Boolean.TRUE.equals(connection.isOnline()) && Boolean.TRUE.equals(connection.isAuthenticated())) {
|
||||
availableConnections.add(connection);
|
||||
}
|
||||
}
|
||||
connections.set(availableConnections);
|
||||
numConnections.set(availableConnections.size());
|
||||
|
||||
// notify update
|
||||
numUpdates.set(numUpdates.get() + 1);
|
||||
|
@ -821,12 +818,6 @@ public final class XmrConnectionService {
|
|||
}
|
||||
}
|
||||
|
||||
private List<MoneroPeer> getOnlinePeers() {
|
||||
return daemon.getPeers().stream()
|
||||
.filter(peer -> peer.isOnline())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private boolean isFixedConnection() {
|
||||
return !"".equals(config.xmrNode) || preferences.getMoneroNodesOption() == XmrNodes.MoneroNodesOption.CUSTOM;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class AppStartupState {
|
|||
isWalletSynced.set(true);
|
||||
});
|
||||
|
||||
xmrConnectionService.numPeersProperty().addListener((observable, oldValue, newValue) -> {
|
||||
xmrConnectionService.numConnectionsProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (xmrConnectionService.hasSufficientPeersForBroadcast())
|
||||
hasSufficientPeersForBroadcast.set(true);
|
||||
});
|
||||
|
|
|
@ -87,7 +87,7 @@ public class P2PNetworkSetup {
|
|||
BooleanProperty initialP2PNetworkDataReceived = new SimpleBooleanProperty();
|
||||
|
||||
p2PNetworkInfoBinding = EasyBind.combine(bootstrapState, bootstrapWarning, p2PService.getNumConnectedPeers(),
|
||||
xmrConnectionService.numPeersProperty(), hiddenServicePublished, initialP2PNetworkDataReceived,
|
||||
xmrConnectionService.numConnectionsProperty(), hiddenServicePublished, initialP2PNetworkDataReceived,
|
||||
(state, warning, numP2pPeers, numXmrPeers, hiddenService, dataReceived) -> {
|
||||
String result;
|
||||
int p2pPeers = (int) numP2pPeers;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue