mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 19:49:32 +00:00
support setting custom node in UI with localhost running
This commit is contained in:
parent
f162cad439
commit
01a57c18f7
5 changed files with 19 additions and 16 deletions
|
@ -399,11 +399,11 @@ public final class XmrConnectionService {
|
|||
public void onConnectionChanged(MoneroRpcConnection connection) {
|
||||
log.info("Local monerod connection changed: " + connection);
|
||||
if (isShutDownStarted || !connectionManager.getAutoSwitch() || !accountService.isAccountOpen()) return;
|
||||
if (xmrLocalNode.isConnected()) {
|
||||
setConnection(connection.getUri()); // switch to local node if connected
|
||||
if (xmrLocalNode.isConnected() && !xmrLocalNode.shouldBeIgnored()) {
|
||||
setConnection(connection.getUri()); // switch to local node if connected and not ignored
|
||||
checkConnection();
|
||||
} 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
|
||||
if (connectionList.getCurrentConnectionUri().isPresent()) {
|
||||
if (connectionList.getCurrentConnectionUri().isPresent() && connectionManager.hasConnection(connectionList.getCurrentConnectionUri().get())) {
|
||||
connectionManager.setConnection(connectionList.getCurrentConnectionUri().get());
|
||||
}
|
||||
|
||||
|
@ -460,7 +460,7 @@ public final class XmrConnectionService {
|
|||
if (coreContext.isApiUser()) connectionManager.setAutoSwitch(connectionList.getAutoSwitch());
|
||||
else connectionManager.setAutoSwitch(true);
|
||||
|
||||
// start local node if used last and offline
|
||||
// start local node if applicable
|
||||
maybeStartLocalNode();
|
||||
|
||||
// update connection
|
||||
|
@ -477,7 +477,7 @@ public final class XmrConnectionService {
|
|||
if (useTorProxy(connection)) connection.setProxyUri(getProxyUri());
|
||||
connectionManager.setConnection(connection);
|
||||
|
||||
// start local node if used last and offline
|
||||
// start local node if applicable
|
||||
maybeStartLocalNode();
|
||||
|
||||
// update connection
|
||||
|
@ -507,7 +507,7 @@ public final class XmrConnectionService {
|
|||
if (HavenoUtils.havenoSetup == null) return;
|
||||
|
||||
// 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 {
|
||||
log.info("Starting local node");
|
||||
xmrLocalNode.startMoneroNode();
|
||||
|
|
|
@ -22,6 +22,7 @@ import haveno.common.util.Utilities;
|
|||
import haveno.core.trade.HavenoUtils;
|
||||
import haveno.core.user.Preferences;
|
||||
import haveno.core.xmr.XmrNodeSettings;
|
||||
import haveno.core.xmr.nodes.XmrNodes;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import monero.common.MoneroConnectionManager;
|
||||
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.
|
||||
*/
|
||||
public boolean shouldBeIgnored() {
|
||||
return config.ignoreLocalXmrNode;
|
||||
return config.ignoreLocalXmrNode || preferences.getMoneroNodesOption() == XmrNodes.MoneroNodesOption.CUSTOM;
|
||||
}
|
||||
|
||||
public void addListener(XmrLocalNodeListener listener) {
|
||||
|
|
|
@ -33,6 +33,7 @@ import haveno.core.payment.PaymentAccount;
|
|||
import haveno.core.payment.PaymentAccountUtil;
|
||||
import haveno.core.xmr.XmrNodeSettings;
|
||||
import haveno.core.xmr.nodes.XmrNodes;
|
||||
import haveno.core.xmr.nodes.XmrNodes.MoneroNodesOption;
|
||||
import haveno.core.xmr.wallet.Restrictions;
|
||||
import haveno.network.p2p.network.BridgeAddressProvider;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
|
@ -316,6 +317,10 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
|||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public MoneroNodesOption getMoneroNodesOption() {
|
||||
return XmrNodes.MoneroNodesOption.values()[getMoneroNodesOptionOrdinal()];
|
||||
}
|
||||
|
||||
public void dontShowAgain(String key, boolean dontShowAgain) {
|
||||
prefPayload.getDontShowAgainMap().put(key, dontShowAgain);
|
||||
requestPersistence();
|
||||
|
|
|
@ -86,6 +86,10 @@ public class XmrNodes {
|
|||
return getXmrNodes(MoneroNodesOption.PUBLIC);
|
||||
}
|
||||
|
||||
public List<XmrNode> getCustomXmrNodes() {
|
||||
return getXmrNodes(MoneroNodesOption.CUSTOM);
|
||||
}
|
||||
|
||||
private List<XmrNode> getXmrNodes(MoneroNodesOption type) {
|
||||
List<XmrNode> nodes = new ArrayList<>();
|
||||
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) {
|
||||
boolean localMoneroNodeShouldBeUsed = xmrLocalNode.shouldBeUsed();
|
||||
useTorForXmrLabel.setDisable(localMoneroNodeShouldBeUsed);
|
||||
moneroNodesLabel.setDisable(localMoneroNodeShouldBeUsed);
|
||||
xmrNodesLabel.setDisable(localMoneroNodeShouldBeUsed);
|
||||
xmrNodesInputTextField.setDisable(localMoneroNodeShouldBeUsed);
|
||||
useProvidedNodesRadio.setDisable(localMoneroNodeShouldBeUsed);
|
||||
useCustomNodesRadio.setDisable(localMoneroNodeShouldBeUsed);
|
||||
usePublicNodesRadio.setDisable(localMoneroNodeShouldBeUsed || isPreventPublicXmrNetwork());
|
||||
usePublicNodesRadio.setDisable(isPreventPublicXmrNetwork());
|
||||
|
||||
XmrNodes.MoneroNodesOption currentMoneroNodesOption = XmrNodes.MoneroNodesOption.values()[preferences.getMoneroNodesOptionOrdinal()];
|
||||
|
||||
|
|
Loading…
Reference in a new issue