mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-26 15:59:37 -05:00
support setting custom node in UI with localhost running
This commit is contained in:
parent
f162cad439
commit
01a57c18f7
@ -399,11 +399,11 @@ public final class XmrConnectionService {
|
|||||||
public void onConnectionChanged(MoneroRpcConnection connection) {
|
public void onConnectionChanged(MoneroRpcConnection connection) {
|
||||||
log.info("Local monerod connection changed: " + connection);
|
log.info("Local monerod connection changed: " + connection);
|
||||||
if (isShutDownStarted || !connectionManager.getAutoSwitch() || !accountService.isAccountOpen()) return;
|
if (isShutDownStarted || !connectionManager.getAutoSwitch() || !accountService.isAccountOpen()) return;
|
||||||
if (xmrLocalNode.isConnected()) {
|
if (xmrLocalNode.isConnected() && !xmrLocalNode.shouldBeIgnored()) {
|
||||||
setConnection(connection.getUri()); // switch to local node if connected
|
setConnection(connection.getUri()); // switch to local node if connected and not ignored
|
||||||
checkConnection();
|
checkConnection();
|
||||||
} else if (getConnection() != null && getConnection().getUri().equals(connection.getUri())) {
|
} else if (getConnection() != null && getConnection().getUri().equals(connection.getUri())) {
|
||||||
setConnection(getBestAvailableConnection()); // switch to best available if disconnected from local node
|
setConnection(getBestAvailableConnection()); // switch to best available connection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -446,7 +446,7 @@ public final class XmrConnectionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// restore last connection
|
// restore last connection
|
||||||
if (connectionList.getCurrentConnectionUri().isPresent()) {
|
if (connectionList.getCurrentConnectionUri().isPresent() && connectionManager.hasConnection(connectionList.getCurrentConnectionUri().get())) {
|
||||||
connectionManager.setConnection(connectionList.getCurrentConnectionUri().get());
|
connectionManager.setConnection(connectionList.getCurrentConnectionUri().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,7 +460,7 @@ public final class XmrConnectionService {
|
|||||||
if (coreContext.isApiUser()) connectionManager.setAutoSwitch(connectionList.getAutoSwitch());
|
if (coreContext.isApiUser()) connectionManager.setAutoSwitch(connectionList.getAutoSwitch());
|
||||||
else connectionManager.setAutoSwitch(true);
|
else connectionManager.setAutoSwitch(true);
|
||||||
|
|
||||||
// start local node if used last and offline
|
// start local node if applicable
|
||||||
maybeStartLocalNode();
|
maybeStartLocalNode();
|
||||||
|
|
||||||
// update connection
|
// update connection
|
||||||
@ -477,7 +477,7 @@ public final class XmrConnectionService {
|
|||||||
if (useTorProxy(connection)) connection.setProxyUri(getProxyUri());
|
if (useTorProxy(connection)) connection.setProxyUri(getProxyUri());
|
||||||
connectionManager.setConnection(connection);
|
connectionManager.setConnection(connection);
|
||||||
|
|
||||||
// start local node if used last and offline
|
// start local node if applicable
|
||||||
maybeStartLocalNode();
|
maybeStartLocalNode();
|
||||||
|
|
||||||
// update connection
|
// update connection
|
||||||
@ -507,7 +507,7 @@ public final class XmrConnectionService {
|
|||||||
if (HavenoUtils.havenoSetup == null) return;
|
if (HavenoUtils.havenoSetup == null) return;
|
||||||
|
|
||||||
// start local node if offline and used as last connection
|
// start local node if offline and used as last connection
|
||||||
if (connectionManager.getConnection() != null && xmrLocalNode.equalsUri(connectionManager.getConnection().getUri()) && !xmrLocalNode.isDetected()) {
|
if (connectionManager.getConnection() != null && xmrLocalNode.equalsUri(connectionManager.getConnection().getUri()) && !xmrLocalNode.isDetected() && !xmrLocalNode.shouldBeIgnored()) {
|
||||||
try {
|
try {
|
||||||
log.info("Starting local node");
|
log.info("Starting local node");
|
||||||
xmrLocalNode.startMoneroNode();
|
xmrLocalNode.startMoneroNode();
|
||||||
|
@ -22,6 +22,7 @@ import haveno.common.util.Utilities;
|
|||||||
import haveno.core.trade.HavenoUtils;
|
import haveno.core.trade.HavenoUtils;
|
||||||
import haveno.core.user.Preferences;
|
import haveno.core.user.Preferences;
|
||||||
import haveno.core.xmr.XmrNodeSettings;
|
import haveno.core.xmr.XmrNodeSettings;
|
||||||
|
import haveno.core.xmr.nodes.XmrNodes;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import monero.common.MoneroConnectionManager;
|
import monero.common.MoneroConnectionManager;
|
||||||
import monero.common.MoneroUtils;
|
import monero.common.MoneroUtils;
|
||||||
@ -102,7 +103,7 @@ public class XmrLocalNode {
|
|||||||
* Returns whether Haveno should ignore a local Monero node even if it is usable.
|
* Returns whether Haveno should ignore a local Monero node even if it is usable.
|
||||||
*/
|
*/
|
||||||
public boolean shouldBeIgnored() {
|
public boolean shouldBeIgnored() {
|
||||||
return config.ignoreLocalXmrNode;
|
return config.ignoreLocalXmrNode || preferences.getMoneroNodesOption() == XmrNodes.MoneroNodesOption.CUSTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(XmrLocalNodeListener listener) {
|
public void addListener(XmrLocalNodeListener listener) {
|
||||||
|
@ -33,6 +33,7 @@ import haveno.core.payment.PaymentAccount;
|
|||||||
import haveno.core.payment.PaymentAccountUtil;
|
import haveno.core.payment.PaymentAccountUtil;
|
||||||
import haveno.core.xmr.XmrNodeSettings;
|
import haveno.core.xmr.XmrNodeSettings;
|
||||||
import haveno.core.xmr.nodes.XmrNodes;
|
import haveno.core.xmr.nodes.XmrNodes;
|
||||||
|
import haveno.core.xmr.nodes.XmrNodes.MoneroNodesOption;
|
||||||
import haveno.core.xmr.wallet.Restrictions;
|
import haveno.core.xmr.wallet.Restrictions;
|
||||||
import haveno.network.p2p.network.BridgeAddressProvider;
|
import haveno.network.p2p.network.BridgeAddressProvider;
|
||||||
import javafx.beans.property.BooleanProperty;
|
import javafx.beans.property.BooleanProperty;
|
||||||
@ -316,6 +317,10 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
|||||||
// API
|
// API
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public MoneroNodesOption getMoneroNodesOption() {
|
||||||
|
return XmrNodes.MoneroNodesOption.values()[getMoneroNodesOptionOrdinal()];
|
||||||
|
}
|
||||||
|
|
||||||
public void dontShowAgain(String key, boolean dontShowAgain) {
|
public void dontShowAgain(String key, boolean dontShowAgain) {
|
||||||
prefPayload.getDontShowAgainMap().put(key, dontShowAgain);
|
prefPayload.getDontShowAgainMap().put(key, dontShowAgain);
|
||||||
requestPersistence();
|
requestPersistence();
|
||||||
|
@ -86,6 +86,10 @@ public class XmrNodes {
|
|||||||
return getXmrNodes(MoneroNodesOption.PUBLIC);
|
return getXmrNodes(MoneroNodesOption.PUBLIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<XmrNode> getCustomXmrNodes() {
|
||||||
|
return getXmrNodes(MoneroNodesOption.CUSTOM);
|
||||||
|
}
|
||||||
|
|
||||||
private List<XmrNode> getXmrNodes(MoneroNodesOption type) {
|
private List<XmrNode> getXmrNodes(MoneroNodesOption type) {
|
||||||
List<XmrNode> nodes = new ArrayList<>();
|
List<XmrNode> nodes = new ArrayList<>();
|
||||||
for (XmrNode node : getAllXmrNodes()) if (node.getType() == type) nodes.add(node);
|
for (XmrNode node : getAllXmrNodes()) if (node.getType() == type) nodes.add(node);
|
||||||
|
@ -434,14 +434,7 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onMoneroPeersToggleSelected(boolean calledFromUser) {
|
private void onMoneroPeersToggleSelected(boolean calledFromUser) {
|
||||||
boolean localMoneroNodeShouldBeUsed = xmrLocalNode.shouldBeUsed();
|
usePublicNodesRadio.setDisable(isPreventPublicXmrNetwork());
|
||||||
useTorForXmrLabel.setDisable(localMoneroNodeShouldBeUsed);
|
|
||||||
moneroNodesLabel.setDisable(localMoneroNodeShouldBeUsed);
|
|
||||||
xmrNodesLabel.setDisable(localMoneroNodeShouldBeUsed);
|
|
||||||
xmrNodesInputTextField.setDisable(localMoneroNodeShouldBeUsed);
|
|
||||||
useProvidedNodesRadio.setDisable(localMoneroNodeShouldBeUsed);
|
|
||||||
useCustomNodesRadio.setDisable(localMoneroNodeShouldBeUsed);
|
|
||||||
usePublicNodesRadio.setDisable(localMoneroNodeShouldBeUsed || isPreventPublicXmrNetwork());
|
|
||||||
|
|
||||||
XmrNodes.MoneroNodesOption currentMoneroNodesOption = XmrNodes.MoneroNodesOption.values()[preferences.getMoneroNodesOptionOrdinal()];
|
XmrNodes.MoneroNodesOption currentMoneroNodesOption = XmrNodes.MoneroNodesOption.values()[preferences.getMoneroNodesOptionOrdinal()];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user