Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 1,694 Lines • ▼ Show 20 Lines | void CWalletTx::GetAmounts(std::list<COutputEntry> &listReceived, | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Scan the block chain (starting in pindexStart) for transactions from or to | * 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 | * us. If fUpdate is true, found transactions that already exist in the wallet | ||||
* will be updated. | * will be updated. | ||||
* | * | ||||
* Returns pointer to the first block in the last contiguous range that was | * Returns null if scan was successful. Otherwise, if a complete rescan was not | ||||
* successfully scanned or elided (elided if pIndexStart points at a block | * possible (due to pruning or corruption), returns pointer to the most recent | ||||
* before CWallet::nTimeFirstKey). Returns null if there is no such range, or | * block that could not be scanned. | ||||
* the range doesn't include chainActive.Tip(). | |||||
*/ | */ | ||||
CBlockIndex *CWallet::ScanForWalletTransactions(CBlockIndex *pindexStart, | CBlockIndex *CWallet::ScanForWalletTransactions(CBlockIndex *pindexStart, | ||||
bool fUpdate) { | bool fUpdate) { | ||||
LOCK2(cs_main, cs_wallet); | |||||
int64_t nNow = GetTime(); | int64_t nNow = GetTime(); | ||||
CBlockIndex *pindex = pindexStart; | CBlockIndex *pindex = pindexStart; | ||||
CBlockIndex *ret = pindexStart; | CBlockIndex *ret = nullptr; | ||||
LOCK2(cs_main, cs_wallet); | |||||
// No need to read and scan block, if block was created before our wallet | // No need to read and scan block, if block was created before our wallet | ||||
// birthday (as adjusted for block time variability) | // birthday (as adjusted for block time variability) | ||||
while (pindex && nTimeFirstKey && | while (pindex && nTimeFirstKey && | ||||
(pindex->GetBlockTime() < (nTimeFirstKey - 7200))) { | (pindex->GetBlockTime() < (nTimeFirstKey - 7200))) { | ||||
pindex = chainActive.Next(pindex); | pindex = chainActive.Next(pindex); | ||||
} | } | ||||
Show All 18 Lines | while (pindex) { | ||||
CBlock block; | CBlock block; | ||||
if (ReadBlockFromDisk(block, pindex, GetConfig())) { | if (ReadBlockFromDisk(block, pindex, GetConfig())) { | ||||
for (size_t posInBlock = 0; posInBlock < block.vtx.size(); | for (size_t posInBlock = 0; posInBlock < block.vtx.size(); | ||||
++posInBlock) { | ++posInBlock) { | ||||
AddToWalletIfInvolvingMe(block.vtx[posInBlock], pindex, | AddToWalletIfInvolvingMe(block.vtx[posInBlock], pindex, | ||||
posInBlock, fUpdate); | posInBlock, fUpdate); | ||||
} | } | ||||
if (!ret) { | |||||
ret = pindex; | |||||
} | |||||
} else { | } else { | ||||
ret = nullptr; | ret = pindex; | ||||
} | } | ||||
pindex = chainActive.Next(pindex); | pindex = chainActive.Next(pindex); | ||||
if (GetTime() >= nNow + 60) { | if (GetTime() >= nNow + 60) { | ||||
nNow = GetTime(); | nNow = GetTime(); | ||||
LogPrintf("Still rescanning. At block %d. Progress=%f\n", | LogPrintf("Still rescanning. At block %d. Progress=%f\n", | ||||
pindex->nHeight, | pindex->nHeight, | ||||
GuessVerificationProgress(chainParams.TxData(), pindex)); | GuessVerificationProgress(chainParams.TxData(), pindex)); | ||||
▲ Show 20 Lines • Show All 2,800 Lines • Show Last 20 Lines |