From b4ddb46f607fca65d243fef322cb517e330c624c Mon Sep 17 00:00:00 2001 From: woodser Date: Fri, 11 Aug 2023 13:07:19 -0400 Subject: [PATCH] always start syncing main wallet after setting connection --- .../core/xmr/wallet/XmrWalletService.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java index d2bbbd94fb..08afa43fbc 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java @@ -824,22 +824,24 @@ public class XmrWalletService { String newProxyUri = connection == null ? null : connection.getProxyUri(); if (wallet == null) maybeInitMainWallet(); else if (wallet instanceof MoneroWalletRpc && !StringUtils.equals(oldProxyUri, newProxyUri)) { - log.info("Restarting main wallet since proxy URI has changed"); + log.info("Restarting main wallet because proxy URI has changed"); closeMainWallet(true); maybeInitMainWallet(); } else { wallet.setDaemonConnection(connection); - if (connection != null) { - wallet.getDaemonConnection().setPrintStackTrace(PRINT_STACK_TRACE); - new Thread(() -> { - try { - wallet.startSyncing(connectionsService.getRefreshPeriodMs()); - if (!Boolean.FALSE.equals(connection.isConnected())) wallet.sync(); - } catch (Exception e) { - log.warn("Failed to sync main wallet after setting daemon connection: " + e.getMessage()); - } - }).start(); - } + } + + // sync wallet on new thread + if (connection != null) { + wallet.getDaemonConnection().setPrintStackTrace(PRINT_STACK_TRACE); + new Thread(() -> { + try { + if (!Boolean.FALSE.equals(connection.isConnected())) wallet.sync(); + wallet.startSyncing(connectionsService.getRefreshPeriodMs()); + } catch (Exception e) { + log.warn("Failed to sync main wallet after setting daemon connection: " + e.getMessage()); + } + }).start(); } log.info("Done setting main wallet daemon connection: " + (connection == null ? null : connection.getUri()));