Skip to content

Commit 24bd5aa

Browse files
committed
do not fail on getHeight() error, sync progress timeout is treated as unresponsive
1 parent 3f27541 commit 24bd5aa

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

core/src/main/java/haveno/core/trade/HavenoUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import haveno.core.trade.statistics.TradeStatisticsManager;
4545
import haveno.core.user.Preferences;
4646
import haveno.core.util.JsonUtil;
47+
import haveno.core.xmr.wallet.XmrWalletBase;
4748
import haveno.core.xmr.wallet.XmrWalletService;
4849
import haveno.network.p2p.NodeAddress;
4950

@@ -626,7 +627,7 @@ public static boolean isReadTimeout(Throwable e) {
626627
}
627628

628629
public static boolean isUnresponsive(Throwable e) {
629-
return isConnectionRefused(e) || isReadTimeout(e);
630+
return isConnectionRefused(e) || isReadTimeout(e) || XmrWalletBase.isSyncWithProgressTimeout(e);
630631
}
631632

632633
public static boolean isNotEnoughSigners(Throwable e) {

core/src/main/java/haveno/core/xmr/wallet/XmrWalletBase.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public abstract class XmrWalletBase {
3131
public static final int SYNC_PROGRESS_TIMEOUT_SECONDS = 120;
3232
public static final int DIRECT_SYNC_WITHIN_BLOCKS = 100;
3333
public static final int SAVE_WALLET_DELAY_SECONDS = 300;
34+
private static final String SYNC_PROGRESS_TIMEOUT_MSG = "Sync progress timeout called";
3435

3536
// inherited
3637
protected MoneroWallet wallet;
@@ -114,12 +115,6 @@ public void onSyncProgress(long height, long startHeight, long endHeight, double
114115
log.warn("Error getting wallet height while syncing with progress: " + e.getMessage());
115116
log.warn(ExceptionUtils.getStackTrace(e));
116117
}
117-
118-
// stop polling and release latch
119-
syncProgressLooper.stop();
120-
syncProgressTimeout.stop();
121-
syncProgressError = e;
122-
syncProgressLatch.countDown();
123118
return;
124119
}
125120
long appliedTargetHeight = repeatSyncToLatestHeight ? xmrConnectionService.getTargetHeight() : targetHeightAtStart;
@@ -168,6 +163,10 @@ public void saveWalletWithDelay() {
168163

169164
// --------------------------------- ABSTRACT -----------------------------
170165

166+
public static boolean isSyncWithProgressTimeout(Throwable e) {
167+
return e.getMessage().equals(SYNC_PROGRESS_TIMEOUT_MSG);
168+
}
169+
171170
public abstract void saveWallet();
172171

173172
public abstract void requestSaveWallet();
@@ -201,7 +200,7 @@ private synchronized void resetSyncProgressTimeout() {
201200
if (syncProgressTimeout != null) syncProgressTimeout.stop();
202201
syncProgressTimeout = UserThread.runAfter(() -> {
203202
if (isShutDownStarted) return;
204-
syncProgressError = new RuntimeException("Sync progress timeout called");
203+
syncProgressError = new RuntimeException(SYNC_PROGRESS_TIMEOUT_MSG);
205204
syncProgressLatch.countDown();
206205
}, SYNC_PROGRESS_TIMEOUT_SECONDS, TimeUnit.SECONDS);
207206
}

0 commit comments

Comments
 (0)