mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-11-16 15:58:08 +00:00
fixes to sync with progress start and target height
Some checks are pending
Some checks are pending
This commit is contained in:
parent
e10f764dc2
commit
0644d0b74a
1 changed files with 9 additions and 7 deletions
|
@ -69,8 +69,9 @@ public class XmrWalletBase {
|
||||||
// set initial state
|
// set initial state
|
||||||
isSyncingWithProgress = true;
|
isSyncingWithProgress = true;
|
||||||
syncProgressError = null;
|
syncProgressError = null;
|
||||||
updateSyncProgress(walletHeight.get());
|
|
||||||
long targetHeightAtStart = xmrConnectionService.getTargetHeight();
|
long targetHeightAtStart = xmrConnectionService.getTargetHeight();
|
||||||
|
syncStartHeight = walletHeight.get();
|
||||||
|
updateSyncProgress(syncStartHeight, targetHeightAtStart);
|
||||||
|
|
||||||
// test connection changing on startup before wallet synced
|
// test connection changing on startup before wallet synced
|
||||||
if (testReconnectOnStartup) {
|
if (testReconnectOnStartup) {
|
||||||
|
@ -88,7 +89,8 @@ public class XmrWalletBase {
|
||||||
wallet.sync(new MoneroWalletListener() {
|
wallet.sync(new MoneroWalletListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSyncProgress(long height, long startHeight, long endHeight, double percentDone, String message) {
|
public void onSyncProgress(long height, long startHeight, long endHeight, double percentDone, String message) {
|
||||||
updateSyncProgress(height);
|
long appliedTargetHeight = repeatSyncToLatestHeight ? xmrConnectionService.getTargetHeight() : targetHeightAtStart;
|
||||||
|
updateSyncProgress(height, appliedTargetHeight);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setWalletSyncedWithProgress();
|
setWalletSyncedWithProgress();
|
||||||
|
@ -111,8 +113,9 @@ public class XmrWalletBase {
|
||||||
syncProgressLatch.countDown();
|
syncProgressLatch.countDown();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateSyncProgress(height);
|
long appliedTargetHeight = repeatSyncToLatestHeight ? xmrConnectionService.getTargetHeight() : targetHeightAtStart;
|
||||||
if (height >= (repeatSyncToLatestHeight ? xmrConnectionService.getTargetHeight() : targetHeightAtStart)) {
|
updateSyncProgress(height, appliedTargetHeight);
|
||||||
|
if (height >= appliedTargetHeight) {
|
||||||
setWalletSyncedWithProgress();
|
setWalletSyncedWithProgress();
|
||||||
syncProgressLatch.countDown();
|
syncProgressLatch.countDown();
|
||||||
}
|
}
|
||||||
|
@ -132,7 +135,7 @@ public class XmrWalletBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSyncProgress(long height) {
|
private void updateSyncProgress(long height, long targetHeight) {
|
||||||
resetSyncProgressTimeout();
|
resetSyncProgressTimeout();
|
||||||
UserThread.execute(() -> {
|
UserThread.execute(() -> {
|
||||||
|
|
||||||
|
@ -141,12 +144,11 @@ public class XmrWalletBase {
|
||||||
|
|
||||||
// new wallet reports height 1 before synced
|
// new wallet reports height 1 before synced
|
||||||
if (height == 1) {
|
if (height == 1) {
|
||||||
downloadListener.progress(0, xmrConnectionService.getTargetHeight() - height, null);
|
downloadListener.progress(0, targetHeight - height, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set progress
|
// set progress
|
||||||
long targetHeight = xmrConnectionService.getTargetHeight();
|
|
||||||
long blocksLeft = targetHeight - walletHeight.get();
|
long blocksLeft = targetHeight - walletHeight.get();
|
||||||
if (syncStartHeight == null) syncStartHeight = walletHeight.get();
|
if (syncStartHeight == null) syncStartHeight = walletHeight.get();
|
||||||
double percent = Math.min(1.0, targetHeight == syncStartHeight ? 1.0 : ((double) walletHeight.get() - syncStartHeight) / (double) (targetHeight - syncStartHeight));
|
double percent = Math.min(1.0, targetHeight == syncStartHeight ? 1.0 : ((double) walletHeight.get() - syncStartHeight) / (double) (targetHeight - syncStartHeight));
|
||||||
|
|
Loading…
Reference in a new issue