From e4b80ef14b61818aabbb9c9bdf465a059af7027f Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 21 Apr 2024 13:51:17 -0400 Subject: [PATCH] do not update from pool on shared wallet sync --- .../haveno/core/xmr/wallet/XmrWalletService.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java index 6c1103b18f..1a7c0bcb2e 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java @@ -381,18 +381,12 @@ public class XmrWalletService { Callable task = () -> wallet.sync(); Future future = syncWalletThreadPool.submit(task); try { - MoneroSyncResult result = future.get(); - wallet.getTxs(); // TODO: this is necessary to sync from pool, otherwise balance can be incorrect - return result; + return future.get(); } catch (Exception e) { throw new MoneroError(e.getMessage()); } } - private MoneroSyncResult syncWallet() { - return syncWallet(wallet); - } - public void saveWallet(MoneroWallet wallet) { saveWallet(wallet, false); } @@ -1426,7 +1420,7 @@ public class XmrWalletService { else { syncWithProgressLooper.stop(); try { - syncWallet(); // ensure finished syncing + doPollWallet(true); } catch (Exception e) { e.printStackTrace(); } @@ -1751,11 +1745,11 @@ public class XmrWalletService { } private void pollWallet() { + if (pollInProgress) return; doPollWallet(true); } private void doPollWallet(boolean updateTxs) { - if (pollInProgress) return; synchronized (pollLock) { pollInProgress = true; try { @@ -1775,7 +1769,7 @@ public class XmrWalletService { if (wallet.getHeight() < xmrConnectionService.getTargetHeight()) wallet.sync(); // fetch transactions from pool and store to cache - // TODO: ideally wallet should sync every poll and then avoid updating from pool on fetching txs + // TODO: ideally wallet should sync every poll and then avoid updating from pool on fetching txs? if (updateTxs) { try { cachedTxs = wallet.getTxs(new MoneroTxQuery().setIncludeOutputs(true));