@@ -1527,6 +1527,8 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool f
1527
1527
CBlockIndex* pindex = pindexStart;
1528
1528
{
1529
1529
LOCK2 (cs_main, cs_wallet);
1530
+ fAbortRescan = false ;
1531
+ fScanningWallet = true ;
1530
1532
1531
1533
// no need to read and scan block, if block was created before
1532
1534
// our wallet birthday (as adjusted for block time variability)
@@ -1536,7 +1538,7 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool f
1536
1538
ShowProgress (_ (" Rescanning..." ), 0 ); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
1537
1539
double dProgressStart = GuessVerificationProgress (chainParams.TxData (), pindex);
1538
1540
double dProgressTip = GuessVerificationProgress (chainParams.TxData (), chainActive.Tip ());
1539
- while (pindex)
1541
+ while (pindex && ! fAbortRescan )
1540
1542
{
1541
1543
if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0 )
1542
1544
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
1558
1560
LogPrintf (" Still rescanning. At block %d. Progress=%f\n " , pindex->nHeight , GuessVerificationProgress (chainParams.TxData (), pindex));
1559
1561
}
1560
1562
}
1563
+ if (pindex && fAbortRescan ) {
1564
+ LogPrintf (" Rescan aborted at block %d. Progress=%f\n " , pindex->nHeight , GuessVerificationProgress (chainParams.TxData (), pindex));
1565
+ }
1561
1566
ShowProgress (_ (" Rescanning..." ), 100 ); // hide progress dialog in GUI
1567
+
1568
+ fScanningWallet = false ;
1562
1569
}
1563
1570
return ret;
1564
1571
}
0 commit comments