@@ -1745,23 +1745,27 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
1745
1745
fAbortRescan = false ;
1746
1746
ShowProgress (_ (" Rescanning..." ), 0 ); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
1747
1747
CBlockIndex* tip = nullptr ;
1748
- double dProgressStart ;
1749
- double dProgressTip ;
1748
+ double progress_begin ;
1749
+ double progress_end ;
1750
1750
{
1751
1751
LOCK (cs_main);
1752
- tip = chainActive.Tip ();
1753
- dProgressStart = GuessVerificationProgress (chainParams.TxData (), pindex);
1754
- dProgressTip = GuessVerificationProgress (chainParams.TxData (), tip);
1752
+ progress_begin = GuessVerificationProgress (chainParams.TxData (), pindex);
1753
+ if (pindexStop == nullptr ) {
1754
+ tip = chainActive.Tip ();
1755
+ progress_end = GuessVerificationProgress (chainParams.TxData (), tip);
1756
+ } else {
1757
+ progress_end = GuessVerificationProgress (chainParams.TxData (), pindexStop);
1758
+ }
1755
1759
}
1756
- double gvp = dProgressStart ;
1760
+ double progress_current = progress_begin ;
1757
1761
while (pindex && !fAbortRescan && !ShutdownRequested ())
1758
1762
{
1759
- if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0 ) {
1760
- ShowProgress (_ (" Rescanning..." ), std::max (1 , std::min (99 , (int )((gvp - dProgressStart ) / (dProgressTip - dProgressStart ) * 100 ))));
1763
+ if (pindex->nHeight % 100 == 0 && progress_end - progress_begin > 0.0 ) {
1764
+ ShowProgress (_ (" Rescanning..." ), std::max (1 , std::min (99 , (int )((progress_current - progress_begin ) / (progress_end - progress_begin ) * 100 ))));
1761
1765
}
1762
1766
if (GetTime () >= nNow + 60 ) {
1763
1767
nNow = GetTime ();
1764
- LogPrintf (" Still rescanning. At block %d. Progress=%f\n " , pindex->nHeight , gvp );
1768
+ LogPrintf (" Still rescanning. At block %d. Progress=%f\n " , pindex->nHeight , progress_current );
1765
1769
}
1766
1770
1767
1771
CBlock block;
@@ -1785,18 +1789,18 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
1785
1789
{
1786
1790
LOCK (cs_main);
1787
1791
pindex = chainActive.Next (pindex);
1788
- gvp = GuessVerificationProgress (chainParams.TxData (), pindex);
1789
- if (tip != chainActive.Tip ()) {
1792
+ progress_current = GuessVerificationProgress (chainParams.TxData (), pindex);
1793
+ if (pindexStop == nullptr && tip != chainActive.Tip ()) {
1790
1794
tip = chainActive.Tip ();
1791
1795
// in case the tip has changed, update progress max
1792
- dProgressTip = GuessVerificationProgress (chainParams.TxData (), tip);
1796
+ progress_end = GuessVerificationProgress (chainParams.TxData (), tip);
1793
1797
}
1794
1798
}
1795
1799
}
1796
1800
if (pindex && fAbortRescan ) {
1797
- LogPrintf (" Rescan aborted at block %d. Progress=%f\n " , pindex->nHeight , gvp );
1801
+ LogPrintf (" Rescan aborted at block %d. Progress=%f\n " , pindex->nHeight , progress_current );
1798
1802
} else if (pindex && ShutdownRequested ()) {
1799
- LogPrintf (" Rescan interrupted by shutdown request at block %d. Progress=%f\n " , pindex->nHeight , gvp );
1803
+ LogPrintf (" Rescan interrupted by shutdown request at block %d. Progress=%f\n " , pindex->nHeight , progress_current );
1800
1804
}
1801
1805
ShowProgress (_ (" Rescanning..." ), 100 ); // hide progress dialog in GUI
1802
1806
}
0 commit comments