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,22 +824,24 @@ 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);
if (connection != null) { }
wallet.getDaemonConnection().setPrintStackTrace(PRINT_STACK_TRACE);
new Thread(() -> { // sync wallet on new thread
try { if (connection != null) {
wallet.startSyncing(connectionsService.getRefreshPeriodMs()); wallet.getDaemonConnection().setPrintStackTrace(PRINT_STACK_TRACE);
if (!Boolean.FALSE.equals(connection.isConnected())) wallet.sync(); new Thread(() -> {
} catch (Exception e) { try {
log.warn("Failed to sync main wallet after setting daemon connection: " + e.getMessage()); if (!Boolean.FALSE.equals(connection.isConnected())) wallet.sync();
} wallet.startSyncing(connectionsService.getRefreshPeriodMs());
}).start(); } 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())); log.info("Done setting main wallet daemon connection: " + (connection == null ? null : connection.getUri()));