mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-10-11 10:08:31 -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;
|
||||
updateSyncProgress(height, appliedTargetHeight);
|
||||
if (height >= appliedTargetHeight) {
|
||||
setWalletSyncedWithProgress();
|
||||
syncProgressLatch.countDown();
|
||||
}
|
||||
});
|
||||
|
@ -187,21 +186,20 @@ public abstract class XmrWalletBase {
|
|||
|
||||
// wait for sync to complete
|
||||
HavenoUtils.awaitLatch(syncProgressLatch);
|
||||
|
||||
// stop polling
|
||||
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?
|
||||
wallet.stopSyncing();
|
||||
saveWalletIfElapsedTime();
|
||||
}
|
||||
|
||||
|
||||
// set synced or throw error
|
||||
if (syncProgressError == null) {
|
||||
setWalletSyncedWithProgress();
|
||||
} else {
|
||||
throw new RuntimeException(syncProgressError);
|
||||
}
|
||||
if (syncProgressError != null) throw new RuntimeException(syncProgressError);
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
isSyncingWithProgress = false;
|
||||
if (syncProgressTimeout != null) syncProgressTimeout.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -272,8 +270,16 @@ public abstract class XmrWalletBase {
|
|||
}
|
||||
|
||||
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;
|
||||
isSyncingWithProgress = false;
|
||||
if (syncProgressTimeout != null) syncProgressTimeout.stop();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue