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();
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);
}
// sync wallet on new thread
if (connection != null) {
wallet.getDaemonConnection().setPrintStackTrace(PRINT_STACK_TRACE);
new Thread(() -> {
try {
wallet.startSyncing(connectionsService.getRefreshPeriodMs());
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()));
}