reinitialize main wallet on same thread as connection change

This commit is contained in:
woodser 2024-07-18 09:14:16 -04:00
parent cb132e727a
commit ebcadb7bed

View file

@ -1304,7 +1304,10 @@ public class XmrWalletService {
}
private void maybeInitMainWallet(boolean sync, int numAttempts) {
ThreadUtils.execute(() -> {
ThreadUtils.execute(() -> doMaybeInitMainWallet(sync, numAttempts), THREAD_ID);
}
private void doMaybeInitMainWallet(boolean sync, int numAttempts) {
synchronized (WALLET_LOCK) {
if (isShutDownStarted) return;
@ -1397,7 +1400,6 @@ public class XmrWalletService {
startPolling();
}
}
}, THREAD_ID);
}
private void resetIfWalletChanged() {
@ -1679,7 +1681,7 @@ public class XmrWalletService {
} else {
log.info("Restarting main wallet because proxy URI has changed, old={}, new={}", oldProxyUri, newProxyUri); // TODO: set proxy without restarting wallet
closeMainWallet(true);
maybeInitMainWallet(false);
doMaybeInitMainWallet(false, MAX_SYNC_ATTEMPTS);
return; // wallet is re-initialized
}
} else {
@ -1846,7 +1848,6 @@ public class XmrWalletService {
synchronized (HavenoUtils.getDaemonLock()) {
try {
cachedTxs = wallet.getTxs(new MoneroTxQuery().setIncludeOutputs(true));
lastLogPollErrorTimestamp = null;
} catch (Exception e) { // fetch from pool can fail
if (!isShutDownStarted) {
if (lastLogPollErrorTimestamp == null || System.currentTimeMillis() - lastLogPollErrorTimestamp > HavenoUtils.LOG_POLL_ERROR_PERIOD_MS) { // limit error logging