diff --git a/core/src/main/java/haveno/core/api/XmrConnectionService.java b/core/src/main/java/haveno/core/api/XmrConnectionService.java index 75be338503..96458a27ac 100644 --- a/core/src/main/java/haveno/core/api/XmrConnectionService.java +++ b/core/src/main/java/haveno/core/api/XmrConnectionService.java @@ -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> peers = new SimpleObjectProperty<>(); + private final ObjectProperty> connections = new SimpleObjectProperty<>(); + private final IntegerProperty numConnections = new SimpleIntegerProperty(0); private final ObjectProperty 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> peerConnectionsProperty() { - return peers; + public ReadOnlyObjectProperty> connectionsProperty() { + return connections; } public ReadOnlyObjectProperty 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()); + // set available connections + List 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 getOnlinePeers() { - return daemon.getPeers().stream() - .filter(peer -> peer.isOnline()) - .collect(Collectors.toList()); - } - private boolean isFixedConnection() { return !"".equals(config.xmrNode) || preferences.getMoneroNodesOption() == XmrNodes.MoneroNodesOption.CUSTOM; } diff --git a/core/src/main/java/haveno/core/app/AppStartupState.java b/core/src/main/java/haveno/core/app/AppStartupState.java index 85da2af9d4..89fe61576a 100644 --- a/core/src/main/java/haveno/core/app/AppStartupState.java +++ b/core/src/main/java/haveno/core/app/AppStartupState.java @@ -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); }); diff --git a/core/src/main/java/haveno/core/app/P2PNetworkSetup.java b/core/src/main/java/haveno/core/app/P2PNetworkSetup.java index 4e90faeb55..69609a4bba 100644 --- a/core/src/main/java/haveno/core/app/P2PNetworkSetup.java +++ b/core/src/main/java/haveno/core/app/P2PNetworkSetup.java @@ -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; diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 4525c6a33e..f3a67e4013 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -1315,6 +1315,8 @@ settings.net.p2pHeader=Haveno network settings.net.onionAddressLabel=My onion address settings.net.xmrNodesLabel=Use custom Monero nodes settings.net.moneroPeersLabel=Connected peers +settings.net.connection=Connection +settings.net.connected=Connected settings.net.useTorForXmrJLabel=Use Tor for Monero network settings.net.useTorForXmrAfterSyncRadio=After wallet is synchronized settings.net.useTorForXmrOffRadio=Never diff --git a/core/src/main/resources/i18n/displayStrings_cs.properties b/core/src/main/resources/i18n/displayStrings_cs.properties index ada00d8344..161a6be719 100644 --- a/core/src/main/resources/i18n/displayStrings_cs.properties +++ b/core/src/main/resources/i18n/displayStrings_cs.properties @@ -1043,6 +1043,8 @@ settings.net.p2pHeader=Síť Haveno settings.net.onionAddressLabel=Moje onion adresa settings.net.xmrNodesLabel=Použijte vlastní Monero node settings.net.moneroPeersLabel=Připojené peer uzly +settings.net.connection=Připojení +settings.net.connected=Připojeno settings.net.useTorForXmrJLabel=Použít Tor pro Monero síť settings.net.moneroNodesLabel=Monero nody, pro připojení settings.net.useProvidedNodesRadio=Použijte nabízené Monero Core nody diff --git a/core/src/main/resources/i18n/displayStrings_de.properties b/core/src/main/resources/i18n/displayStrings_de.properties index 79f6704ade..198b5999f2 100644 --- a/core/src/main/resources/i18n/displayStrings_de.properties +++ b/core/src/main/resources/i18n/displayStrings_de.properties @@ -1043,6 +1043,8 @@ settings.net.p2pHeader=Haveno-Netzwerk settings.net.onionAddressLabel=Meine Onion-Adresse settings.net.xmrNodesLabel=Spezifische Monero-Knoten verwenden settings.net.moneroPeersLabel=Verbundene Peers +settings.net.connection=Verbindung +settings.net.connected=Verbunden settings.net.useTorForXmrJLabel=Tor für das Monero-Netzwerk verwenden settings.net.moneroNodesLabel=Mit Monero-Knoten verbinden settings.net.useProvidedNodesRadio=Bereitgestellte Monero-Core-Knoten verwenden diff --git a/core/src/main/resources/i18n/displayStrings_es.properties b/core/src/main/resources/i18n/displayStrings_es.properties index c9d60a7020..17115d059d 100644 --- a/core/src/main/resources/i18n/displayStrings_es.properties +++ b/core/src/main/resources/i18n/displayStrings_es.properties @@ -1044,6 +1044,8 @@ settings.net.p2pHeader=Red Haveno settings.net.onionAddressLabel=Mi dirección onion settings.net.xmrNodesLabel=Utilizar nodos Monero personalizados settings.net.moneroPeersLabel=Pares conectados +settings.net.connection=Conexión +settings.net.connected=Conectado settings.net.useTorForXmrJLabel=Usar Tor para la red Monero settings.net.moneroNodesLabel=Nodos Monero para conectarse settings.net.useProvidedNodesRadio=Utilizar nodos Monero Core proporcionados diff --git a/core/src/main/resources/i18n/displayStrings_fa.properties b/core/src/main/resources/i18n/displayStrings_fa.properties index 7f18e3c321..f6db7fffd2 100644 --- a/core/src/main/resources/i18n/displayStrings_fa.properties +++ b/core/src/main/resources/i18n/displayStrings_fa.properties @@ -1040,6 +1040,8 @@ settings.net.p2pHeader=Haveno network settings.net.onionAddressLabel=آدرس onion من settings.net.xmrNodesLabel=استفاده از گره‌های Monero اختصاصی settings.net.moneroPeersLabel=همتایان متصل +settings.net.connection=اتصال +settings.net.connected=متصل settings.net.useTorForXmrJLabel=استفاده از Tor برای شبکه مونرو settings.net.moneroNodesLabel=گره‌های Monero در دسترس settings.net.useProvidedNodesRadio=استفاده از نودهای بیتکوین ارائه شده diff --git a/core/src/main/resources/i18n/displayStrings_fr.properties b/core/src/main/resources/i18n/displayStrings_fr.properties index a510fbac58..400f58cdc4 100644 --- a/core/src/main/resources/i18n/displayStrings_fr.properties +++ b/core/src/main/resources/i18n/displayStrings_fr.properties @@ -1045,6 +1045,8 @@ settings.net.p2pHeader=Le réseau Haveno settings.net.onionAddressLabel=Mon adresse onion settings.net.xmrNodesLabel=Utiliser des nœuds Monero personnalisés settings.net.moneroPeersLabel=Pairs connectés +settings.net.connection=Connexion +settings.net.connected=Connecté settings.net.useTorForXmrJLabel=Utiliser Tor pour le réseau Monero settings.net.moneroNodesLabel=Nœuds Monero pour se connecter à settings.net.useProvidedNodesRadio=Utiliser les nœuds Monero Core fournis diff --git a/core/src/main/resources/i18n/displayStrings_it.properties b/core/src/main/resources/i18n/displayStrings_it.properties index 09e98ca4d6..4a8e6844d0 100644 --- a/core/src/main/resources/i18n/displayStrings_it.properties +++ b/core/src/main/resources/i18n/displayStrings_it.properties @@ -1042,6 +1042,8 @@ settings.net.p2pHeader=Rete Haveno settings.net.onionAddressLabel=Il mio indirizzo onion settings.net.xmrNodesLabel=Usa nodi Monero personalizzati settings.net.moneroPeersLabel=Peer connessi +settings.net.connection=Connessione +settings.net.connected=Connesso settings.net.useTorForXmrJLabel=Usa Tor per la rete Monero settings.net.moneroNodesLabel=Nodi Monero a cui connettersi settings.net.useProvidedNodesRadio=Usa i nodi Monero Core forniti diff --git a/core/src/main/resources/i18n/displayStrings_ja.properties b/core/src/main/resources/i18n/displayStrings_ja.properties index 8e6085bc80..afd3cd69d3 100644 --- a/core/src/main/resources/i18n/displayStrings_ja.properties +++ b/core/src/main/resources/i18n/displayStrings_ja.properties @@ -1043,6 +1043,8 @@ settings.net.p2pHeader=Havenoネットワーク settings.net.onionAddressLabel=私のonionアドレス settings.net.xmrNodesLabel=任意のモネロノードを使う settings.net.moneroPeersLabel=接続されたピア +settings.net.connection=接続 +settings.net.connected=接続されました settings.net.useTorForXmrJLabel=MoneroネットワークにTorを使用 settings.net.moneroNodesLabel=接続するMoneroノード: settings.net.useProvidedNodesRadio=提供されたMonero Core ノードを使う diff --git a/core/src/main/resources/i18n/displayStrings_pt-br.properties b/core/src/main/resources/i18n/displayStrings_pt-br.properties index 51f2e33388..da457db45b 100644 --- a/core/src/main/resources/i18n/displayStrings_pt-br.properties +++ b/core/src/main/resources/i18n/displayStrings_pt-br.properties @@ -1044,6 +1044,8 @@ settings.net.p2pHeader=Rede Haveno settings.net.onionAddressLabel=Meu endereço onion settings.net.xmrNodesLabel=Usar nodos personalizados do Monero settings.net.moneroPeersLabel=Pares conectados +settings.net.connection=Conexão +settings.net.connected=Conectado settings.net.useTorForXmrJLabel=Usar Tor na rede Monero settings.net.moneroNodesLabel=Conexão a nodos do Monero settings.net.useProvidedNodesRadio=Usar nodos do Monero Core fornecidos diff --git a/core/src/main/resources/i18n/displayStrings_pt.properties b/core/src/main/resources/i18n/displayStrings_pt.properties index 9be31eefa8..b3985a5692 100644 --- a/core/src/main/resources/i18n/displayStrings_pt.properties +++ b/core/src/main/resources/i18n/displayStrings_pt.properties @@ -1041,6 +1041,8 @@ settings.net.p2pHeader=Rede do Haveno settings.net.onionAddressLabel=O meu endereço onion settings.net.xmrNodesLabel=Usar nós de Monero personalizados settings.net.moneroPeersLabel=Pares conectados +settings.net.connection=Conexão +settings.net.connected=Conectado settings.net.useTorForXmrJLabel=Usar Tor para a rede de Monero settings.net.moneroNodesLabel=Nós de Monero para conectar settings.net.useProvidedNodesRadio=Usar nós de Monero Core providenciados diff --git a/core/src/main/resources/i18n/displayStrings_ru.properties b/core/src/main/resources/i18n/displayStrings_ru.properties index 49b37f4c98..51d98e1ef4 100644 --- a/core/src/main/resources/i18n/displayStrings_ru.properties +++ b/core/src/main/resources/i18n/displayStrings_ru.properties @@ -1040,6 +1040,8 @@ settings.net.p2pHeader=Haveno network settings.net.onionAddressLabel=Мой onion-адрес settings.net.xmrNodesLabel=Использовать особые узлы Monero settings.net.moneroPeersLabel=Подключенные пиры +settings.net.connection=Соединение +settings.net.connected=Подключено settings.net.useTorForXmrJLabel=Использовать Tor для сети Monero settings.net.moneroNodesLabel=Узлы Monero для подключения settings.net.useProvidedNodesRadio=Использовать предоставленные узлы Monero Core diff --git a/core/src/main/resources/i18n/displayStrings_th.properties b/core/src/main/resources/i18n/displayStrings_th.properties index 15b8751843..5460e1074f 100644 --- a/core/src/main/resources/i18n/displayStrings_th.properties +++ b/core/src/main/resources/i18n/displayStrings_th.properties @@ -1040,6 +1040,8 @@ settings.net.p2pHeader=Haveno network settings.net.onionAddressLabel=ที่อยู่ onion ของฉัน settings.net.xmrNodesLabel=ใช้โหนดเครือข่าย Monero ที่กำหนดเอง settings.net.moneroPeersLabel=เชื่อมต่อกับเน็ตเวิร์ก peers แล้ว +settings.net.connection=การเชื่อมต่อ +settings.net.connected=เชื่อมต่อ settings.net.useTorForXmrJLabel=ใช้ Tor สำหรับเครือข่าย Monero settings.net.moneroNodesLabel=ใช้โหนดเครือข่าย Monero เพื่อเชื่อมต่อ settings.net.useProvidedNodesRadio=ใช้โหนดเครือข่าย Monero ที่ให้มา diff --git a/core/src/main/resources/i18n/displayStrings_tr.properties b/core/src/main/resources/i18n/displayStrings_tr.properties index e7161baaa3..d807f48aa5 100644 --- a/core/src/main/resources/i18n/displayStrings_tr.properties +++ b/core/src/main/resources/i18n/displayStrings_tr.properties @@ -1310,6 +1310,8 @@ settings.net.p2pHeader=Haveno ağı settings.net.onionAddressLabel=Onion adresim settings.net.xmrNodesLabel=Özel Monero düğümleri kullan settings.net.moneroPeersLabel=Bağlı eşler +settings.net.connection=Bağlantı +settings.net.connected=Bağlı settings.net.useTorForXmrJLabel=Monero ağı için Tor kullan settings.net.useTorForXmrAfterSyncRadio=Cüzdan senkronize edildikten sonra settings.net.useTorForXmrOffRadio=Asla diff --git a/core/src/main/resources/i18n/displayStrings_vi.properties b/core/src/main/resources/i18n/displayStrings_vi.properties index 5929dd94ad..321d1bb6b6 100644 --- a/core/src/main/resources/i18n/displayStrings_vi.properties +++ b/core/src/main/resources/i18n/displayStrings_vi.properties @@ -1042,6 +1042,8 @@ settings.net.p2pHeader=Haveno network settings.net.onionAddressLabel=Địa chỉ onion của tôi settings.net.xmrNodesLabel=Sử dụng nút Monero thông dụng settings.net.moneroPeersLabel=Các đối tác được kết nối +settings.net.connection=Kết nối +settings.net.connected=Kết nối settings.net.useTorForXmrJLabel=Sử dụng Tor cho mạng Monero settings.net.moneroNodesLabel=nút Monero để kết nối settings.net.useProvidedNodesRadio=Sử dụng các nút Monero Core đã cung cấp diff --git a/core/src/main/resources/i18n/displayStrings_zh-hans.properties b/core/src/main/resources/i18n/displayStrings_zh-hans.properties index 0ea093e121..2709bb2645 100644 --- a/core/src/main/resources/i18n/displayStrings_zh-hans.properties +++ b/core/src/main/resources/i18n/displayStrings_zh-hans.properties @@ -1043,6 +1043,8 @@ settings.net.p2pHeader=Haveno 网络 settings.net.onionAddressLabel=我的匿名地址 settings.net.xmrNodesLabel=使用自定义比特币主节点 settings.net.moneroPeersLabel=已连接节点 +settings.net.connection=连接 +settings.net.connected=连接 settings.net.useTorForXmrJLabel=使用 Tor 连接 Monero 网络 settings.net.moneroNodesLabel=需要连接 Monero settings.net.useProvidedNodesRadio=使用公共比特币核心节点 diff --git a/core/src/main/resources/i18n/displayStrings_zh-hant.properties b/core/src/main/resources/i18n/displayStrings_zh-hant.properties index 95fad5ea7f..64f5082a45 100644 --- a/core/src/main/resources/i18n/displayStrings_zh-hant.properties +++ b/core/src/main/resources/i18n/displayStrings_zh-hant.properties @@ -1043,6 +1043,8 @@ settings.net.p2pHeader=Haveno 網絡 settings.net.onionAddressLabel=我的匿名地址 settings.net.xmrNodesLabel=使用自定义Monero节点 settings.net.moneroPeersLabel=已連接節點 +settings.net.connection=連接 +settings.net.connected=連接完成 settings.net.useTorForXmrJLabel=使用 Tor 連接 Monero 網絡 settings.net.moneroNodesLabel=需要連接 Monero settings.net.useProvidedNodesRadio=使用公共比特幣核心節點 diff --git a/desktop/src/main/java/haveno/desktop/main/settings/network/MoneroNetworkListItem.java b/desktop/src/main/java/haveno/desktop/main/settings/network/MoneroNetworkListItem.java index 80bd094fc9..fea0ef6f34 100644 --- a/desktop/src/main/java/haveno/desktop/main/settings/network/MoneroNetworkListItem.java +++ b/desktop/src/main/java/haveno/desktop/main/settings/network/MoneroNetworkListItem.java @@ -17,28 +17,23 @@ package haveno.desktop.main.settings.network; -import monero.daemon.model.MoneroPeer; +import haveno.core.locale.Res; +import monero.common.MoneroRpcConnection; public class MoneroNetworkListItem { - private final MoneroPeer peer; - - public MoneroNetworkListItem(MoneroPeer peer) { - this.peer = peer; + private final MoneroRpcConnection connection; + private final boolean connected; + + public MoneroNetworkListItem(MoneroRpcConnection connection, boolean connected) { + this.connection = connection; + this.connected = connected; } - public String getOnionAddress() { - return peer.getHost() + ":" + peer.getPort(); + public String getAddress() { + return connection.getUri(); } - public String getVersion() { - return ""; - } - - public String getSubVersion() { - return ""; - } - - public String getHeight() { - return String.valueOf(peer.getHeight()); + public String getConnected() { + return connected ? Res.get("settings.net.connected") : ""; } } diff --git a/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.fxml b/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.fxml index 3e9d25428e..1f3e8840d7 100644 --- a/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.fxml +++ b/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.fxml @@ -45,27 +45,17 @@ - - + + - + - + - + - - - - - - - - - - - + diff --git a/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.java b/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.java index 931a6e3526..546a55505f 100644 --- a/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.java +++ b/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.java @@ -44,7 +44,6 @@ import haveno.desktop.main.overlays.windows.TorNetworkSettingsWindow; import haveno.desktop.util.GUIUtil; import haveno.network.p2p.P2PService; import haveno.network.p2p.network.Statistic; -import java.util.List; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import static javafx.beans.binding.Bindings.createStringBinding; @@ -63,7 +62,6 @@ import javafx.scene.control.TextField; import javafx.scene.control.Toggle; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.GridPane; -import monero.daemon.model.MoneroPeer; import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.Subscription; @@ -79,7 +77,7 @@ public class NetworkSettingsView extends ActivatableView { @FXML TextField onionAddress, sentDataTextField, receivedDataTextField, chainHeightTextField; @FXML - Label p2PPeersLabel, moneroPeersLabel; + Label p2PPeersLabel, moneroConnectionsLabel; @FXML RadioButton useTorForXmrAfterSyncRadio, useTorForXmrOffRadio, useTorForXmrOnRadio; @FXML @@ -87,13 +85,12 @@ public class NetworkSettingsView extends ActivatableView { @FXML TableView p2pPeersTableView; @FXML - TableView moneroPeersTableView; + TableView moneroConnectionsTableView; @FXML TableColumn onionAddressColumn, connectionTypeColumn, creationDateColumn, roundTripTimeColumn, sentBytesColumn, receivedBytesColumn, peerTypeColumn; @FXML - TableColumn moneroPeerAddressColumn, moneroPeerVersionColumn, - moneroPeerSubVersionColumn, moneroPeerHeightColumn; + TableColumn moneroConnectionAddressColumn, moneroConnectionConnectedColumn; @FXML Label rescanOutputsLabel; @FXML @@ -116,7 +113,7 @@ public class NetworkSettingsView extends ActivatableView { private final SortedList moneroSortedList = new SortedList<>(moneroNetworkListItems); private Subscription numP2PPeersSubscription; - private Subscription moneroPeersSubscription; + private Subscription moneroConnectionsSubscription; private Subscription moneroBlockHeightSubscription; private Subscription nodeAddressSubscription; private ChangeListener xmrNodesInputTextFieldFocusListener; @@ -156,17 +153,15 @@ public class NetworkSettingsView extends ActivatableView { p2pHeader.setText(Res.get("settings.net.p2pHeader")); onionAddress.setPromptText(Res.get("settings.net.onionAddressLabel")); xmrNodesLabel.setText(Res.get("settings.net.xmrNodesLabel")); - moneroPeersLabel.setText(Res.get("settings.net.moneroPeersLabel")); + moneroConnectionsLabel.setText(Res.get("settings.net.moneroPeersLabel")); useTorForXmrLabel.setText(Res.get("settings.net.useTorForXmrJLabel")); useTorForXmrAfterSyncRadio.setText(Res.get("settings.net.useTorForXmrAfterSyncRadio")); useTorForXmrOffRadio.setText(Res.get("settings.net.useTorForXmrOffRadio")); useTorForXmrOnRadio.setText(Res.get("settings.net.useTorForXmrOnRadio")); moneroNodesLabel.setText(Res.get("settings.net.moneroNodesLabel")); - moneroPeerAddressColumn.setGraphic(new AutoTooltipLabel(Res.get("settings.net.onionAddressColumn"))); - moneroPeerAddressColumn.getStyleClass().add("first-column"); - moneroPeerVersionColumn.setGraphic(new AutoTooltipLabel(Res.get("settings.net.versionColumn"))); - moneroPeerSubVersionColumn.setGraphic(new AutoTooltipLabel(Res.get("settings.net.subVersionColumn"))); - moneroPeerHeightColumn.setGraphic(new AutoTooltipLabel(Res.get("settings.net.heightColumn"))); + moneroConnectionAddressColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.address"))); + moneroConnectionAddressColumn.getStyleClass().add("first-column"); + moneroConnectionConnectedColumn.setGraphic(new AutoTooltipLabel(Res.get("settings.net.connection"))); localhostXmrNodeInfoLabel.setText(Res.get("settings.net.localhostXmrNodeInfo")); useProvidedNodesRadio.setText(Res.get("settings.net.useProvidedNodesRadio")); useCustomNodesRadio.setText(Res.get("settings.net.useCustomNodesRadio")); @@ -192,19 +187,19 @@ public class NetworkSettingsView extends ActivatableView { rescanOutputsLabel.setVisible(false); rescanOutputsButton.setVisible(false); - GridPane.setMargin(moneroPeersLabel, new Insets(4, 0, 0, 0)); - GridPane.setValignment(moneroPeersLabel, VPos.TOP); + GridPane.setMargin(moneroConnectionsLabel, new Insets(4, 0, 0, 0)); + GridPane.setValignment(moneroConnectionsLabel, VPos.TOP); GridPane.setMargin(p2PPeersLabel, new Insets(4, 0, 0, 0)); GridPane.setValignment(p2PPeersLabel, VPos.TOP); - moneroPeersTableView.setMinHeight(180); - moneroPeersTableView.setPrefHeight(180); - moneroPeersTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); - moneroPeersTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData"))); - moneroPeersTableView.getSortOrder().add(moneroPeerAddressColumn); - moneroPeerAddressColumn.setSortType(TableColumn.SortType.ASCENDING); - + moneroConnectionAddressColumn.setSortType(TableColumn.SortType.ASCENDING); + moneroConnectionConnectedColumn.setSortType(TableColumn.SortType.DESCENDING); + moneroConnectionsTableView.setMinHeight(180); + moneroConnectionsTableView.setPrefHeight(180); + moneroConnectionsTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); + moneroConnectionsTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData"))); + moneroConnectionsTableView.getSortOrder().add(moneroConnectionConnectedColumn); p2pPeersTableView.setMinHeight(180); p2pPeersTableView.setPrefHeight(180); @@ -309,11 +304,11 @@ public class NetworkSettingsView extends ActivatableView { rescanOutputsButton.setOnAction(event -> GUIUtil.rescanOutputs(preferences)); - moneroPeersSubscription = EasyBind.subscribe(connectionService.peerConnectionsProperty(), - this::updateMoneroPeersTable); + moneroConnectionsSubscription = EasyBind.subscribe(connectionService.connectionsProperty(), + connections -> updateMoneroConnectionsTable()); moneroBlockHeightSubscription = EasyBind.subscribe(connectionService.chainHeightProperty(), - this::updateChainHeightTextField); + height -> updateMoneroConnectionsTable()); nodeAddressSubscription = EasyBind.subscribe(p2PService.getNetworkNode().nodeAddressProperty(), nodeAddress -> onionAddress.setText(nodeAddress == null ? @@ -333,8 +328,8 @@ public class NetworkSettingsView extends ActivatableView { Statistic.numTotalReceivedMessagesPerSecProperty().get()), Statistic.numTotalReceivedMessagesPerSecProperty())); - moneroSortedList.comparatorProperty().bind(moneroPeersTableView.comparatorProperty()); - moneroPeersTableView.setItems(moneroSortedList); + moneroSortedList.comparatorProperty().bind(moneroConnectionsTableView.comparatorProperty()); + moneroConnectionsTableView.setItems(moneroSortedList); p2pSortedList.comparatorProperty().bind(p2pPeersTableView.comparatorProperty()); p2pPeersTableView.setItems(p2pSortedList); @@ -355,8 +350,8 @@ public class NetworkSettingsView extends ActivatableView { if (nodeAddressSubscription != null) nodeAddressSubscription.unsubscribe(); - if (moneroPeersSubscription != null) - moneroPeersSubscription.unsubscribe(); + if (moneroConnectionsSubscription != null) + moneroConnectionsSubscription.unsubscribe(); if (moneroBlockHeightSubscription != null) moneroBlockHeightSubscription.unsubscribe(); @@ -521,13 +516,15 @@ public class NetworkSettingsView extends ActivatableView { .collect(Collectors.toList())); } - private void updateMoneroPeersTable(List peers) { - moneroNetworkListItems.clear(); - if (peers != null) { - moneroNetworkListItems.setAll(peers.stream() - .map(MoneroNetworkListItem::new) + private void updateMoneroConnectionsTable() { + UserThread.execute(() -> { + if (connectionService.isShutDownStarted()) return; // ignore if shutting down + moneroNetworkListItems.clear(); + moneroNetworkListItems.setAll(connectionService.getConnections().stream() + .map(connection -> new MoneroNetworkListItem(connection, Boolean.TRUE.equals(connection.isConnected()) && connection == connectionService.getConnection())) .collect(Collectors.toList())); - } + updateChainHeightTextField(connectionService.chainHeightProperty().get()); + }); } private void updateChainHeightTextField(Number chainHeight) {