diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index f0b0ee2873..a290b1e2c7 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -3184,13 +3184,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model { private void syncWalletIfBehind() { synchronized (walletLock) { if (isWalletBehind()) { - - // TODO: local tests have timing failures unless sync called directly - if (xmrConnectionService.getTargetHeight() - walletHeight.get() < XmrWalletBase.DIRECT_SYNC_WITHIN_BLOCKS) { - xmrWalletService.syncWallet(wallet); // TODO: always running this causes "Wallet is not connected to daemon" error - } else { - syncWithProgress(); - } + syncWithProgress(); walletHeight.set(wallet.getHeight()); } } 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 a2d01ae5b2..83119f4a25 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java @@ -59,11 +59,7 @@ import java.util.List; import java.util.Optional; import java.util.Set; import java.util.TreeSet; -import java.util.concurrent.Callable; import java.util.concurrent.CopyOnWriteArraySet; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; import java.util.stream.Collectors; import java.util.stream.Stream; import javafx.beans.property.LongProperty; @@ -91,7 +87,6 @@ import monero.wallet.model.MoneroIncomingTransfer; import monero.wallet.model.MoneroOutputQuery; import monero.wallet.model.MoneroOutputWallet; import monero.wallet.model.MoneroSubaddress; -import monero.wallet.model.MoneroSyncResult; import monero.wallet.model.MoneroTxConfig; import monero.wallet.model.MoneroTxPriority; import monero.wallet.model.MoneroTxQuery; @@ -142,7 +137,6 @@ public class XmrWalletService extends XmrWalletBase { private ChangeListener walletInitListener; private TradeManager tradeManager; - private ExecutorService syncWalletThreadPool = Executors.newFixedThreadPool(10); // TODO: adjust based on connection type private final Object lock = new Object(); private TaskLooper pollLooper; @@ -360,23 +354,6 @@ public class XmrWalletService extends XmrWalletBase { return useNativeXmrWallet && MoneroUtils.isNativeLibraryLoaded(); } - /** - * Sync the given wallet in a thread pool with other wallets. - */ - public MoneroSyncResult syncWallet(MoneroWallet wallet) { - synchronized (HavenoUtils.getDaemonLock()) { // TODO: lock defeats purpose of thread pool - Callable task = () -> { - return wallet.sync(); - }; - Future future = syncWalletThreadPool.submit(task); - try { - return future.get(); - } catch (Exception e) { - throw new MoneroError(e.getMessage()); - } - } - } - public void saveWallet(MoneroWallet wallet) { saveWallet(wallet, false); } @@ -2057,13 +2034,7 @@ public class XmrWalletService extends XmrWalletBase { // sync wallet if behind daemon if (walletHeight.get() < xmrConnectionService.getTargetHeight()) { synchronized (walletLock) { // avoid long sync from blocking other operations - - // TODO: local tests have timing failures unless sync called directly - if (xmrConnectionService.getTargetHeight() - walletHeight.get() < XmrWalletBase.DIRECT_SYNC_WITHIN_BLOCKS) { - syncMainWallet(); - } else { - syncWithProgress(); - } + syncWithProgress(); } } @@ -2119,14 +2090,6 @@ public class XmrWalletService extends XmrWalletBase { } } - private MoneroSyncResult syncMainWallet() { - synchronized (walletLock) { - MoneroSyncResult result = syncWallet(wallet); - walletHeight.set(wallet.getHeight()); - return result; - } - } - public boolean isWalletConnectedToDaemon() { synchronized (walletLock) { try {