mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-10-12 18:40:46 -04:00
save wallet after syncing before stopping timeout
This commit is contained in:
parent
eaf23af15f
commit
53d8a7fafc
1 changed files with 18 additions and 12 deletions
|
@ -178,7 +178,6 @@ public abstract class XmrWalletBase {
|
||||||
long appliedTargetHeight = repeatSyncToLatestHeight ? xmrConnectionService.getTargetHeight() : targetHeightAtStart;
|
long appliedTargetHeight = repeatSyncToLatestHeight ? xmrConnectionService.getTargetHeight() : targetHeightAtStart;
|
||||||
updateSyncProgress(height, appliedTargetHeight);
|
updateSyncProgress(height, appliedTargetHeight);
|
||||||
if (height >= appliedTargetHeight) {
|
if (height >= appliedTargetHeight) {
|
||||||
setWalletSyncedWithProgress();
|
|
||||||
syncProgressLatch.countDown();
|
syncProgressLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -187,21 +186,20 @@ public abstract class XmrWalletBase {
|
||||||
|
|
||||||
// wait for sync to complete
|
// wait for sync to complete
|
||||||
HavenoUtils.awaitLatch(syncProgressLatch);
|
HavenoUtils.awaitLatch(syncProgressLatch);
|
||||||
|
|
||||||
// stop polling
|
|
||||||
syncProgressLooper.stop();
|
syncProgressLooper.stop();
|
||||||
syncProgressTimeout.stop();
|
|
||||||
if (wallet != null) { // can become null if interrupted by force close
|
|
||||||
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?
|
// set synced or throw error
|
||||||
wallet.stopSyncing();
|
if (syncProgressError == null) {
|
||||||
saveWalletIfElapsedTime();
|
setWalletSyncedWithProgress();
|
||||||
}
|
} else {
|
||||||
|
throw new RuntimeException(syncProgressError);
|
||||||
}
|
}
|
||||||
if (syncProgressError != null) throw new RuntimeException(syncProgressError);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
isSyncingWithProgress = false;
|
isSyncingWithProgress = false;
|
||||||
|
if (syncProgressTimeout != null) syncProgressTimeout.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,8 +270,16 @@ public abstract class XmrWalletBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setWalletSyncedWithProgress() {
|
private void setWalletSyncedWithProgress() {
|
||||||
|
|
||||||
|
// stop syncing and save wallet if elapsed time
|
||||||
|
if (wallet != null) { // can become null if interrupted by force close
|
||||||
|
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?
|
||||||
|
wallet.stopSyncing();
|
||||||
|
saveWalletIfElapsedTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// update state
|
||||||
wasWalletSynced = true;
|
wasWalletSynced = true;
|
||||||
isSyncingWithProgress = false;
|
|
||||||
if (syncProgressTimeout != null) syncProgressTimeout.stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue