mirror of
https://github.com/boldsuck/haveno.git
synced 2024-12-22 20:19:21 +00:00
fallback from custom node to provided nodes on startup error #923
Co-authored-by: nsec1 <167650977+nsec1@users.noreply.github.com>
This commit is contained in:
parent
4494af8bc0
commit
26a5ffcb31
3 changed files with 29 additions and 18 deletions
|
@ -557,6 +557,7 @@ public final class XmrConnectionService {
|
|||
|
||||
// update polling
|
||||
doPollDaemon();
|
||||
if (currentConnection != getConnection()) return; // polling can change connection
|
||||
UserThread.runAfter(() -> updatePolling(), getRefreshPeriodMs() / 1000);
|
||||
|
||||
// notify listeners in parallel
|
||||
|
@ -607,13 +608,22 @@ public final class XmrConnectionService {
|
|||
try {
|
||||
lastInfo = daemon.getInfo();
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
log.warn("Failed to fetch daemon info, trying to switch to best connection: " + e.getMessage());
|
||||
switchToBestConnection();
|
||||
lastInfo = daemon.getInfo();
|
||||
} catch (Exception e2) {
|
||||
throw e2; // caught internally
|
||||
|
||||
// skip handling if shutting down
|
||||
if (isShutDownStarted) return;
|
||||
|
||||
// fallback to provided nodes if custom connection fails on startup
|
||||
if (lastInfo == null && "".equals(config.xmrNode) && preferences.getMoneroNodesOption() == XmrNodes.MoneroNodesOption.CUSTOM) {
|
||||
log.warn("Failed to fetch daemon info from custom node on startup, falling back to provided nodes: " + e.getMessage());
|
||||
preferences.setMoneroNodesOptionOrdinal(XmrNodes.MoneroNodesOption.PROVIDED.ordinal());
|
||||
initializeConnections();
|
||||
return;
|
||||
}
|
||||
|
||||
// switch to best connection
|
||||
log.warn("Failed to fetch daemon info, trying to switch to best connection: " + e.getMessage());
|
||||
switchToBestConnection();
|
||||
lastInfo = daemon.getInfo(); // caught internally if still fails
|
||||
}
|
||||
|
||||
// connected to daemon
|
||||
|
|
|
@ -262,11 +262,11 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
|||
cssThemeProperty.set(prefPayload.getCssTheme());
|
||||
|
||||
|
||||
// if no valid Bitcoin block explorer is set, select the 1st valid Bitcoin block explorer
|
||||
ArrayList<BlockChainExplorer> btcExplorers = getBlockChainExplorers();
|
||||
// if no valid Monero block explorer is set, select the 1st valid Monero block explorer
|
||||
ArrayList<BlockChainExplorer> xmrExplorers = getBlockChainExplorers();
|
||||
if (getBlockChainExplorer() == null ||
|
||||
getBlockChainExplorer().name.length() == 0) {
|
||||
setBlockChainExplorer(btcExplorers.get(0));
|
||||
setBlockChainExplorer(xmrExplorers.get(0));
|
||||
}
|
||||
tradeCurrenciesAsObservable.addAll(prefPayload.getTraditionalCurrencies());
|
||||
tradeCurrenciesAsObservable.addAll(prefPayload.getCryptoCurrencies());
|
||||
|
@ -278,8 +278,8 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
|||
|
||||
if (xmrNodesFromOptions != null && !xmrNodesFromOptions.isEmpty()) {
|
||||
if (getMoneroNodes() != null && !getMoneroNodes().equals(xmrNodesFromOptions)) {
|
||||
log.warn("The Bitcoin node(s) from the program argument and the one(s) persisted in the UI are different. " +
|
||||
"The Bitcoin node(s) {} from the program argument will be used.", xmrNodesFromOptions);
|
||||
log.warn("The Monero node(s) from the program argument and the one(s) persisted in the UI are different. " +
|
||||
"The Monero node(s) {} from the program argument will be used.", xmrNodesFromOptions);
|
||||
}
|
||||
setMoneroNodes(xmrNodesFromOptions);
|
||||
setMoneroNodesOptionOrdinal(XmrNodes.MoneroNodesOption.CUSTOM.ordinal());
|
||||
|
@ -567,8 +567,8 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
|||
requestPersistence();
|
||||
}
|
||||
|
||||
public void setMoneroNodes(String bitcoinNodes) {
|
||||
prefPayload.setMoneroNodes(bitcoinNodes);
|
||||
public void setMoneroNodes(String moneroNodes) {
|
||||
prefPayload.setMoneroNodes(moneroNodes);
|
||||
requestPersistence();
|
||||
}
|
||||
|
||||
|
@ -658,8 +658,8 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
|||
requestPersistence();
|
||||
}
|
||||
|
||||
public void setMoneroNodesOptionOrdinal(int bitcoinNodesOptionOrdinal) {
|
||||
prefPayload.setMoneroNodesOptionOrdinal(bitcoinNodesOptionOrdinal);
|
||||
public void setMoneroNodesOptionOrdinal(int moneroNodesOptionOrdinal) {
|
||||
prefPayload.setMoneroNodesOptionOrdinal(moneroNodesOptionOrdinal);
|
||||
requestPersistence();
|
||||
}
|
||||
|
||||
|
@ -892,7 +892,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
|||
|
||||
void setSortMarketCurrenciesNumerically(boolean sortMarketCurrenciesNumerically);
|
||||
|
||||
void setMoneroNodes(String bitcoinNodes);
|
||||
void setMoneroNodes(String moneroNodes);
|
||||
|
||||
void setUseCustomWithdrawalTxFee(boolean useCustomWithdrawalTxFee);
|
||||
|
||||
|
@ -926,7 +926,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
|||
|
||||
void setUseTorForXmrOrdinal(int useTorForXmrOrdinal);
|
||||
|
||||
void setMoneroNodesOptionOrdinal(int bitcoinNodesOption);
|
||||
void setMoneroNodesOptionOrdinal(int moneroNodesOption);
|
||||
|
||||
void setReferralId(String referralId);
|
||||
|
||||
|
|
|
@ -1545,6 +1545,7 @@ public class XmrWalletService {
|
|||
// open wallet
|
||||
config.setNetworkType(getMoneroNetworkType());
|
||||
config.setServer(connection);
|
||||
log.info("Opening full wallet " + config.getPath() + " with monerod=" + connection.getUri());
|
||||
walletFull = MoneroWalletFull.openWallet(config);
|
||||
if (walletFull.getDaemonConnection() != null) walletFull.getDaemonConnection().setPrintStackTrace(PRINT_RPC_STACK_TRACE);
|
||||
log.info("Done opening full wallet " + config.getPath());
|
||||
|
@ -1604,7 +1605,7 @@ public class XmrWalletService {
|
|||
if (!applyProxyUri) connection.setProxyUri(null);
|
||||
|
||||
// open wallet
|
||||
log.info("Opening RPC wallet " + config.getPath() + " connected to daemon " + connection.getUri());
|
||||
log.info("Opening RPC wallet " + config.getPath() + " with monerod=" + connection.getUri());
|
||||
config.setServer(connection);
|
||||
walletRpc.openWallet(config);
|
||||
if (walletRpc.getDaemonConnection() != null) walletRpc.getDaemonConnection().setPrintStackTrace(PRINT_RPC_STACK_TRACE);
|
||||
|
|
Loading…
Reference in a new issue