support --ignoreLocalXmrNode startup flag

This commit is contained in:
woodser 2024-05-09 17:39:39 -04:00
parent 416761af41
commit 3cdd88b569
3 changed files with 18 additions and 3 deletions

View file

@ -480,6 +480,7 @@ haveno-daemon-mainnet:
--apiPassword=apitest \ --apiPassword=apitest \
--apiPort=1201 \ --apiPort=1201 \
--useNativeXmrWallet=false \ --useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \
haveno-desktop-mainnet: haveno-desktop-mainnet:
./haveno-desktop$(APP_EXT) \ ./haveno-desktop$(APP_EXT) \
@ -491,6 +492,7 @@ haveno-desktop-mainnet:
--apiPassword=apitest \ --apiPassword=apitest \
--apiPort=1201 \ --apiPort=1201 \
--useNativeXmrWallet=false \ --useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \
user1-daemon-mainnet: user1-daemon-mainnet:
./haveno-daemon$(APP_EXT) \ ./haveno-daemon$(APP_EXT) \
@ -503,6 +505,7 @@ user1-daemon-mainnet:
--apiPort=1202 \ --apiPort=1202 \
--passwordRequired=false \ --passwordRequired=false \
--useNativeXmrWallet=false \ --useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \
user1-desktop-mainnet: user1-desktop-mainnet:
./haveno-desktop$(APP_EXT) \ ./haveno-desktop$(APP_EXT) \
@ -514,6 +517,7 @@ user1-desktop-mainnet:
--apiPassword=apitest \ --apiPassword=apitest \
--apiPort=1202 \ --apiPort=1202 \
--useNativeXmrWallet=false \ --useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \
user2-daemon-mainnet: user2-daemon-mainnet:
./haveno-daemon$(APP_EXT) \ ./haveno-daemon$(APP_EXT) \
@ -526,6 +530,7 @@ user2-daemon-mainnet:
--apiPort=1203 \ --apiPort=1203 \
--passwordRequired=false \ --passwordRequired=false \
--useNativeXmrWallet=false \ --useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \
user2-desktop-mainnet: user2-desktop-mainnet:
./haveno-desktop$(APP_EXT) \ ./haveno-desktop$(APP_EXT) \
@ -537,6 +542,7 @@ user2-desktop-mainnet:
--apiPassword=apitest \ --apiPassword=apitest \
--apiPort=1203 \ --apiPort=1203 \
--useNativeXmrWallet=false \ --useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \
user3-desktop-mainnet: user3-desktop-mainnet:
./haveno-desktop$(APP_EXT) \ ./haveno-desktop$(APP_EXT) \
@ -548,3 +554,4 @@ user3-desktop-mainnet:
--apiPassword=apitest \ --apiPassword=apitest \
--apiPort=1204 \ --apiPort=1204 \
--useNativeXmrWallet=false \ --useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \

View file

@ -238,7 +238,9 @@ public final class XmrConnectionService {
public MoneroRpcConnection getBestAvailableConnection() { public MoneroRpcConnection getBestAvailableConnection() {
accountService.checkAccountOpen(); accountService.checkAccountOpen();
return connectionManager.getBestAvailableConnection(); List<MoneroRpcConnection> ignoredConnections = new ArrayList<MoneroRpcConnection>();
if (xmrLocalNode.shouldBeIgnored() && connectionManager.hasConnection(xmrLocalNode.getUri())) ignoredConnections.add(connectionManager.getConnectionByUri(xmrLocalNode.getUri()));
return connectionManager.getBestAvailableConnection(ignoredConnections.toArray(new MoneroRpcConnection[0]));
} }
public void setAutoSwitch(boolean autoSwitch) { public void setAutoSwitch(boolean autoSwitch) {
@ -458,8 +460,10 @@ public final class XmrConnectionService {
// restore last connection // restore last connection
if (connectionList.getCurrentConnectionUri().isPresent() && connectionManager.hasConnection(connectionList.getCurrentConnectionUri().get())) { if (connectionList.getCurrentConnectionUri().isPresent() && connectionManager.hasConnection(connectionList.getCurrentConnectionUri().get())) {
if (!HavenoUtils.isLocalHost(connectionList.getCurrentConnectionUri().get()) || !xmrLocalNode.shouldBeIgnored()) {
connectionManager.setConnection(connectionList.getCurrentConnectionUri().get()); connectionManager.setConnection(connectionList.getCurrentConnectionUri().get());
} }
}
// set connection proxies // set connection proxies
log.info("TOR proxy URI: " + getProxyUri()); log.info("TOR proxy URI: " + getProxyUri());

View file

@ -81,7 +81,7 @@ public class XmrLocalNode {
public XmrLocalNode(Config config, Preferences preferences) { public XmrLocalNode(Config config, Preferences preferences) {
this.config = config; this.config = config;
this.preferences = preferences; this.preferences = preferences;
this.daemon = new MoneroDaemonRpc("http://" + HavenoUtils.LOOPBACK_HOST + ":" + rpcPort); this.daemon = new MoneroDaemonRpc(getUri());
// initialize connection manager to listen to local connection // initialize connection manager to listen to local connection
this.connectionManager = new MoneroConnectionManager().setConnection(daemon.getRpcConnection()); this.connectionManager = new MoneroConnectionManager().setConnection(daemon.getRpcConnection());
@ -92,6 +92,10 @@ public class XmrLocalNode {
this.connectionManager.startPolling(REFRESH_PERIOD_LOCAL_MS); this.connectionManager.startPolling(REFRESH_PERIOD_LOCAL_MS);
} }
public String getUri() {
return "http://" + HavenoUtils.LOOPBACK_HOST + ":" + rpcPort;
}
/** /**
* Returns whether Haveno should use a local Monero node, meaning that a node was * Returns whether Haveno should use a local Monero node, meaning that a node was
* detected and conditions under which it should be ignored have not been met. If * detected and conditions under which it should be ignored have not been met. If