Skip to content

Commit c545fd1

Browse files
committed
remove stack trace, request switch on poll until fully initialized
1 parent 24bd5aa commit c545fd1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,6 +2814,7 @@ private void doPollWallet() {
28142814
}
28152815

28162816
// poll wallet
2817+
MoneroRpcConnection sourceConnection = xmrConnectionService.getConnection();
28172818
try {
28182819

28192820
// skip if shut down started
@@ -2906,7 +2907,6 @@ private void doPollWallet() {
29062907

29072908
// rescan spent outputs to detect unconfirmed payout tx
29082909
if (isPayoutExpected && wallet.getBalance().compareTo(BigInteger.ZERO) > 0) {
2909-
MoneroRpcConnection sourceConnection = xmrConnectionService.getConnection();
29102910
try {
29112911
rescanSpent(true);
29122912
} catch (Exception e) {
@@ -2956,7 +2956,10 @@ private void doPollWallet() {
29562956
}
29572957
}
29582958
} catch (Exception e) {
2959-
if (HavenoUtils.isUnresponsive(e)) {
2959+
if (!(e instanceof IllegalStateException) && !isShutDownStarted && !wasWalletPolled.get()) { // request connection switch if failure on first poll
2960+
ThreadUtils.execute(() -> requestSwitchToNextBestConnection(sourceConnection), getId());
2961+
}
2962+
if (HavenoUtils.isUnresponsive(e)) { // wallet can be stuck a while
29602963
if (isShutDownStarted) forceCloseWallet();
29612964
else forceRestartTradeWallet();
29622965
} else {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ public void onSyncProgress(long height, long startHeight, long endHeight, double
113113
} catch (Exception e) {
114114
if (wallet != null && !isShutDownStarted) {
115115
log.warn("Error getting wallet height while syncing with progress: " + e.getMessage());
116-
log.warn(ExceptionUtils.getStackTrace(e));
117116
}
118117
return;
119118
}
@@ -133,12 +132,12 @@ public void onSyncProgress(long height, long startHeight, long endHeight, double
133132
// stop polling
134133
syncProgressLooper.stop();
135134
syncProgressTimeout.stop();
135+
isSyncingWithProgress = false;
136136
if (wallet != null) { // can become null if interrupted by force close
137137
if (syncProgressError == null || !HavenoUtils.isUnresponsive(syncProgressError)) { // TODO: skipping stop sync if unresponsive because wallet will hang. if unresponsive, wallet is assumed to be force restarted by caller, but that should be done internally here instead of externally?
138138
wallet.stopSyncing();
139139
}
140140
}
141-
isSyncingWithProgress = false;
142141
if (syncProgressError != null) throw new RuntimeException(syncProgressError);
143142
}
144143
}
@@ -164,7 +163,7 @@ public void saveWalletWithDelay() {
164163
// --------------------------------- ABSTRACT -----------------------------
165164

166165
public static boolean isSyncWithProgressTimeout(Throwable e) {
167-
return e.getMessage().equals(SYNC_PROGRESS_TIMEOUT_MSG);
166+
return e.getMessage().contains(SYNC_PROGRESS_TIMEOUT_MSG);
168167
}
169168

170169
public abstract void saveWallet();

0 commit comments

Comments
 (0)