always start syncing main wallet after setting connection

This commit is contained in:
woodser 2023-08-11 13:07:19 -04:00
parent 703756caae
commit b4ddb46f60

View File

@ -824,23 +824,25 @@ public class XmrWalletService {
String newProxyUri = connection == null ? null : connection.getProxyUri(); String newProxyUri = connection == null ? null : connection.getProxyUri();
if (wallet == null) maybeInitMainWallet(); if (wallet == null) maybeInitMainWallet();
else if (wallet instanceof MoneroWalletRpc && !StringUtils.equals(oldProxyUri, newProxyUri)) { 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); closeMainWallet(true);
maybeInitMainWallet(); maybeInitMainWallet();
} else { } else {
wallet.setDaemonConnection(connection); wallet.setDaemonConnection(connection);
}
// sync wallet on new thread
if (connection != null) { if (connection != null) {
wallet.getDaemonConnection().setPrintStackTrace(PRINT_STACK_TRACE); wallet.getDaemonConnection().setPrintStackTrace(PRINT_STACK_TRACE);
new Thread(() -> { new Thread(() -> {
try { try {
wallet.startSyncing(connectionsService.getRefreshPeriodMs());
if (!Boolean.FALSE.equals(connection.isConnected())) wallet.sync(); if (!Boolean.FALSE.equals(connection.isConnected())) wallet.sync();
wallet.startSyncing(connectionsService.getRefreshPeriodMs());
} catch (Exception e) { } catch (Exception e) {
log.warn("Failed to sync main wallet after setting daemon connection: " + e.getMessage()); log.warn("Failed to sync main wallet after setting daemon connection: " + e.getMessage());
} }
}).start(); }).start();
} }
}
log.info("Done setting main wallet daemon connection: " + (connection == null ? null : connection.getUri())); log.info("Done setting main wallet daemon connection: " + (connection == null ? null : connection.getUri()));
} }