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