Skip to content

Commit

Permalink
support --ignoreLocalXmrNode startup flag
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed May 9, 2024
1 parent 416761a commit 3cdd88b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ haveno-daemon-mainnet:
--apiPassword=apitest \
--apiPort=1201 \
--useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \

haveno-desktop-mainnet:
./haveno-desktop$(APP_EXT) \
Expand All @@ -491,6 +492,7 @@ haveno-desktop-mainnet:
--apiPassword=apitest \
--apiPort=1201 \
--useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \

user1-daemon-mainnet:
./haveno-daemon$(APP_EXT) \
Expand All @@ -503,6 +505,7 @@ user1-daemon-mainnet:
--apiPort=1202 \
--passwordRequired=false \
--useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \

user1-desktop-mainnet:
./haveno-desktop$(APP_EXT) \
Expand All @@ -514,6 +517,7 @@ user1-desktop-mainnet:
--apiPassword=apitest \
--apiPort=1202 \
--useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \

user2-daemon-mainnet:
./haveno-daemon$(APP_EXT) \
Expand All @@ -526,6 +530,7 @@ user2-daemon-mainnet:
--apiPort=1203 \
--passwordRequired=false \
--useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \

user2-desktop-mainnet:
./haveno-desktop$(APP_EXT) \
Expand All @@ -537,6 +542,7 @@ user2-desktop-mainnet:
--apiPassword=apitest \
--apiPort=1203 \
--useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \

user3-desktop-mainnet:
./haveno-desktop$(APP_EXT) \
Expand All @@ -548,3 +554,4 @@ user3-desktop-mainnet:
--apiPassword=apitest \
--apiPort=1204 \
--useNativeXmrWallet=false \
--ignoreLocalXmrNode=false \
8 changes: 6 additions & 2 deletions core/src/main/java/haveno/core/api/XmrConnectionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ public void stopCheckingConnection() {

public MoneroRpcConnection getBestAvailableConnection() {
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) {
Expand Down Expand Up @@ -458,7 +460,9 @@ public void onConnectionChanged(MoneroRpcConnection connection) {

// restore last connection
if (connectionList.getCurrentConnectionUri().isPresent() && connectionManager.hasConnection(connectionList.getCurrentConnectionUri().get())) {
connectionManager.setConnection(connectionList.getCurrentConnectionUri().get());
if (!HavenoUtils.isLocalHost(connectionList.getCurrentConnectionUri().get()) || !xmrLocalNode.shouldBeIgnored()) {
connectionManager.setConnection(connectionList.getCurrentConnectionUri().get());
}
}

// set connection proxies
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/haveno/core/api/XmrLocalNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class XmrLocalNode {
public XmrLocalNode(Config config, Preferences preferences) {
this.config = config;
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
this.connectionManager = new MoneroConnectionManager().setConnection(daemon.getRpcConnection());
Expand All @@ -92,6 +92,10 @@ public XmrLocalNode(Config config, Preferences preferences) {
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
* detected and conditions under which it should be ignored have not been met. If
Expand Down

0 comments on commit 3cdd88b

Please sign in to comment.