@@ -1527,6 +1527,8 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool f
15271527 CBlockIndex* pindex = pindexStart;
15281528 {
15291529 LOCK2 (cs_main, cs_wallet);
1530+ fAbortRescan = false ;
1531+ fScanningWallet = true ;
15301532
15311533 // no need to read and scan block, if block was created before
15321534 // our wallet birthday (as adjusted for block time variability)
@@ -1536,7 +1538,7 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool f
15361538 ShowProgress (_ (" Rescanning..." ), 0 ); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
15371539 double dProgressStart = GuessVerificationProgress (chainParams.TxData (), pindex);
15381540 double dProgressTip = GuessVerificationProgress (chainParams.TxData (), chainActive.Tip ());
1539- while (pindex)
1541+ while (pindex && ! fAbortRescan )
15401542 {
15411543 if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0 )
15421544 ShowProgress (_ (" Rescanning..." ), std::max (1 , std::min (99 , (int )((GuessVerificationProgress (chainParams.TxData (), pindex) - dProgressStart) / (dProgressTip - dProgressStart) * 100 ))));
@@ -1558,7 +1560,12 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool f
15581560 LogPrintf (" Still rescanning. At block %d. Progress=%f\n " , pindex->nHeight , GuessVerificationProgress (chainParams.TxData (), pindex));
15591561 }
15601562 }
1563+ if (pindex && fAbortRescan ) {
1564+ LogPrintf (" Rescan aborted at block %d. Progress=%f\n " , pindex->nHeight , GuessVerificationProgress (chainParams.TxData (), pindex));
1565+ }
15611566 ShowProgress (_ (" Rescanning..." ), 100 ); // hide progress dialog in GUI
1567+
1568+ fScanningWallet = false ;
15621569 }
15631570 return ret;
15641571}
0 commit comments