src/wallet/wallet.cpp
CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
{
    int64_t nNow = GetTime();
    const CChainParams& chainParams = Params();

    CBlockIndex* pindex = pindexStart;
    CBlockIndex* ret = pindexStart;
    {
        LOCK2(cs_main, cs_wallet);

        // no need to read and scan block, if block was created before
        // our wallet birthday (as adjusted for block time variability)
        while (pindex && nTimeFirstKey && (pindex->GetBlockTime() < (nTimeFirstKey - TIMESTAMP_WINDOW)))
            pindex = chainActive.Next(pindex);

        ShowProgress(_("Rescanning..."), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
        double dProgressStart = Checkpoints::GuessVerificationProgress(chainParams.TxData(), pindex, false);
        double dProgressTip = Checkpoints::GuessVerificationProgress(chainParams.TxData(), chainActive.Tip(), false);
        while (pindex)
        {
            if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0)
                ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((Checkpoints::GuessVerificationProgress(chainParams.TxData(), pindex, false) - dProgressStart) / (dProgressTip - dProgressStart) * 100))));

            CBlock block;
            if (ReadBlockFromDisk(block, pindex, Params().GetConsensus())) {
                for (size_t posInBlock = 0; posInBlock < block.vtx.size(); ++posInBlock) {
                    AddToWalletIfInvolvingMe(*block.vtx[posInBlock], pindex, posInBlock, fUpdate, true);
                }
                if (!ret) {
                    ret = pindex;
                }
            } else {
                ret = nullptr;
            }
            pindex = chainActive.Next(pindex);
            if (GetTime() >= nNow + 60) {
                nNow = GetTime();
                LogPrintf("Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, Checkpoints::GuessVerificationProgress(chainParams.TxData(), pindex));
            }
        }
        ShowProgress(_("Rescanning..."), 100); // hide progress dialog in GUI
    }
    return ret;
}
/**
 * Scan the block chain (starting in pindexStart) for transactions
 * from or to us. If fUpdate is true, found transactions that already
 * exist in the wallet will be updated.
 *
 * Returns pointer to the first block in the last contiguous range that was
 * successfully scanned or elided (elided if pIndexStart points at a block
 * before CWallet::nTimeFirstKey). Returns null if there is no such range, or
 * the range doesn't include chainActive.Tip().
 */
Scan the block chain (starting in pindexStart) for transactions
from or to us. If fUpdate is true, found transactions that already
exist in the wallet will be updated.

Returns pointer to the first block in the last contiguous range that was
successfully scanned or elided (elided if pIndexStart points at a block
before CWallet::nTimeFirstKey). Returns null if there is no such range, or
the range doesn't include chainActive.Tip().
Scan the block chain ( starting in pindexStart ) for transactions from or to us . If fUpdate is true found transactions that already exist in the wallet will be updated . Returns pointer to the first block in the last contiguous range that was successfully scanned or elided ( elided if pIndexStart points at a block before CWallet :: nTimeFirstKey ) . Returns null if there is no such range or the range doesn ' t include chainActive . Tip () .
CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
{
    int64_t nNow = GetTime();
    const CChainParams& chainParams = Params();
    CBlockIndex* pindex = pindexStart;
    CBlockIndex* ret = pindexStart;
    {
        LOCK2(cs_main, cs_wallet);
        while (pindex && nTimeFirstKey && (pindex->GetBlockTime() < (nTimeFirstKey - TIMESTAMP_WINDOW)))
            pindex = chainActive.Next(pindex);
        ShowProgress(_("Rescanning..."), 0); 
        double dProgressStart = Checkpoints::GuessVerificationProgress(chainParams.TxData(), pindex, false);
        double dProgressTip = Checkpoints::GuessVerificationProgress(chainParams.TxData(), chainActive.Tip(), false);
        while (pindex)
        {
            if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0)
                ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((Checkpoints::GuessVerificationProgress(chainParams.TxData(), pindex, false) - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
            CBlock block;
            if (ReadBlockFromDisk(block, pindex, Params().GetConsensus())) {
                for (size_t posInBlock = 0; posInBlock < block.vtx.size(); ++posInBlock) {
                    AddToWalletIfInvolvingMe(*block.vtx[posInBlock], pindex, posInBlock, fUpdate, true);
                }
                if (!ret) {
                    ret = pindex;
                }
            } else {
                ret = nullptr;
            }
            pindex = chainActive.Next(pindex);
            if (GetTime() >= nNow + 60) {
                nNow = GetTime();
                LogPrintf("Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, Checkpoints::GuessVerificationProgress(chainParams.TxData(), pindex));
            }
        }
        ShowProgress(_("Rescanning..."), 100); 
    }
    return ret;
}
CBlockIndex * CWallet :: ScanForWalletTransactions ( CBlockIndex * pindexStart , bool fUpdate ) { int64_t nNow = GetTime ( ) ; const CChainParams & chainParams = Params ( ) ; CBlockIndex * pindex = pindexStart ; CBlockIndex * ret = pindexStart ; { LOCK2 ( cs_main , cs_wallet ) ; while ( pindex && nTimeFirstKey && ( pindex -> GetBlockTime ( ) < ( nTimeFirstKey - TIMESTAMP_WINDOW ) ) ) pindex = chainActive . Next ( pindex ) ; ShowProgress ( _ ( " " ) , 0 ) ; double dProgressStart = Checkpoints :: GuessVerificationProgress ( chainParams . TxData ( ) , pindex , false ) ; double dProgressTip = Checkpoints :: GuessVerificationProgress ( chainParams . TxData ( ) , chainActive . Tip ( ) , false ) ; while ( pindex ) { if ( pindex -> nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0 ) ShowProgress ( _ ( " " ) , std :: max ( 1 , std :: min ( 99 , ( int ) ( ( Checkpoints :: GuessVerificationProgress ( chainParams . TxData ( ) , pindex , false ) - dProgressStart ) / ( dProgressTip - dProgressStart ) * 100 ) ) ) ) ; CBlock block ; if ( ReadBlockFromDisk ( block , pindex , Params ( ) . GetConsensus ( ) ) ) { for ( size_t posInBlock = 0 ; posInBlock < block . vtx . size ( ) ; ++ posInBlock ) { AddToWalletIfInvolvingMe ( * block . vtx [ posInBlock ] , pindex , posInBlock , fUpdate , true ) ; } if ( ! ret ) { ret = pindex ; } } else { ret = nullptr ; } pindex = chainActive . Next ( pindex ) ; if ( GetTime ( ) >= nNow + 60 ) { nNow = GetTime ( ) ; LogPrintf ( " \n " , pindex -> nHeight , Checkpoints :: GuessVerificationProgress ( chainParams . TxData ( ) , pindex ) ) ; } } ShowProgress ( _ ( " " ) , 100 ) ; } return ret ; }
Scan the block chain (starting in pindexStart) for transactions
 from or to us.
Scan the block chain ( starting in pindexStart ) for transactions from or to us .
// no need to read and scan block, if block was created before // our wallet birthday (as adjusted for block time variability) // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup // hide progress dialog in GUI