src/wallet.cpp
// 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.
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.
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 .
int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
{
    int ret = 0;
    int64_t nNow = GetTime();
    CBlockIndex* pindex = pindexStart;
    {
        LOCK2(cs_main, cs_wallet);
        while (pindex && nTimeFirstKey && (pindex->nTime < (nTimeFirstKey - 7200)))
            pindex = pindex->pnext;
        ShowProgress(_("Rescanning..."), 0); 
        double dProgressStart = GuessVerificationProgress(pindex);
        double dProgressTip = GuessVerificationProgress(pindexBest);
        LogPrintf("[Rescan] Start - pindexBest->nHeight=%d, pindex->nHeight=%d,  dProgressStart=%lf, dProgressTip=%lf\n",
                  pindexBest->nHeight, pindex->nHeight, dProgressStart, dProgressTip);
        while (pindex)
        {
            if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0)
            {
                ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((GuessVerificationProgress(pindex) -
                                                 dProgressStart) / (dProgressTip - dProgressStart) * 100))));
            }
            if (GetTime() >= nNow + 30)
            {
                nNow = GetTime();
                LogPrintf("[Rescan] Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, GuessVerificationProgress(pindex));
            }
            CBlock block;
            block.ReadFromDisk(pindex, true);
            BOOST_FOREACH(CTransaction& tx, block.vtx)
            {
                if (AddToWalletIfInvolvingMe(tx, &block, fUpdate))
                    ret++;
            }
            pindex = pindex->pnext;
        }
        LogPrintf("[Rescan] Completed - %d transactions identified as part of this wallet.\n", ret);
        ShowProgress(_("Rescanning..."), 100); 
    }
    return ret;
}
int CWallet :: ScanForWalletTransactions ( CBlockIndex * pindexStart , bool fUpdate ) { int ret = 0 ; int64_t nNow = GetTime ( ) ; CBlockIndex * pindex = pindexStart ; { LOCK2 ( cs_main , cs_wallet ) ; while ( pindex && nTimeFirstKey && ( pindex -> nTime < ( nTimeFirstKey - 7200 ) ) ) pindex = pindex -> pnext ; ShowProgress ( _ ( " " ) , 0 ) ; double dProgressStart = GuessVerificationProgress ( pindex ) ; double dProgressTip = GuessVerificationProgress ( pindexBest ) ; LogPrintf ( " \n " , pindexBest -> nHeight , pindex -> nHeight , dProgressStart , dProgressTip ) ; while ( pindex ) { if ( pindex -> nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0 ) { ShowProgress ( _ ( " " ) , std :: max ( 1 , std :: min ( 99 , ( int ) ( ( GuessVerificationProgress ( pindex ) - dProgressStart ) / ( dProgressTip - dProgressStart ) * 100 ) ) ) ) ; } if ( GetTime ( ) >= nNow + 30 ) { nNow = GetTime ( ) ; LogPrintf ( " \n " , pindex -> nHeight , GuessVerificationProgress ( pindex ) ) ; } CBlock block ; block . ReadFromDisk ( pindex , true ) ; BOOST_FOREACH ( CTransaction & tx , block . vtx ) { if ( AddToWalletIfInvolvingMe ( tx , & block , fUpdate ) ) ret ++ ; } pindex = pindex -> pnext ; } LogPrintf ( " \n " , ret ) ; 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