Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 1,727 Lines • ▼ Show 20 Lines | CBlockIndex *CWallet::ScanForWalletTransactions(CBlockIndex *pindexStart, | ||||
int64_t nNow = GetTime(); | int64_t nNow = GetTime(); | ||||
if (pindexStop) { | if (pindexStop) { | ||||
assert(pindexStop->nHeight >= pindexStart->nHeight); | assert(pindexStop->nHeight >= pindexStart->nHeight); | ||||
} | } | ||||
CBlockIndex *pindex = pindexStart; | CBlockIndex *pindex = pindexStart; | ||||
CBlockIndex *ret = nullptr; | CBlockIndex *ret = nullptr; | ||||
{ | |||||
LOCK2(cs_main, cs_wallet); | LOCK2(cs_main, cs_wallet); | ||||
fAbortRescan = false; | fAbortRescan = false; | ||||
fScanningWallet = true; | fScanningWallet = true; | ||||
// Show rescan progress in GUI as dialog or on splashscreen, if -rescan on | // Show rescan progress in GUI as dialog or on splashscreen, if -rescan | ||||
// startup. | // on startup. | ||||
ShowProgress(_("Rescanning..."), 0); | ShowProgress(_("Rescanning..."), 0); | ||||
double dProgressStart = | double dProgressStart = | ||||
GuessVerificationProgress(chainParams.TxData(), pindex); | GuessVerificationProgress(chainParams.TxData(), pindex); | ||||
double dProgressTip = | double dProgressTip = | ||||
GuessVerificationProgress(chainParams.TxData(), chainActive.Tip()); | GuessVerificationProgress(chainParams.TxData(), chainActive.Tip()); | ||||
while (pindex && !fAbortRescan) { | while (pindex && !fAbortRescan) { | ||||
if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0) { | if (pindex->nHeight % 100 == 0 && | ||||
dProgressTip - dProgressStart > 0.0) { | |||||
ShowProgress( | ShowProgress( | ||||
_("Rescanning..."), | _("Rescanning..."), | ||||
std::max(1, | std::max(1, std::min<int>( | ||||
std::min<int>(99, (GuessVerificationProgress( | 99, (GuessVerificationProgress( | ||||
chainParams.TxData(), pindex) - | chainParams.TxData(), pindex) - | ||||
dProgressStart) / | dProgressStart) / | ||||
(dProgressTip - dProgressStart) * | (dProgressTip - dProgressStart) * | ||||
100))); | 100))); | ||||
} | } | ||||
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); | ||||
} | } | ||||
} else { | } else { | ||||
ret = pindex; | ret = pindex; | ||||
} | } | ||||
if (pindex == pindexStop) { | if (pindex == pindexStop) { | ||||
break; | break; | ||||
} | } | ||||
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)); | ||||
} | } | ||||
} | } | ||||
if (pindex && fAbortRescan) { | if (pindex && fAbortRescan) { | ||||
LogPrintf("Rescan aborted at block %d. Progress=%f\n", pindex->nHeight, | LogPrintf("Rescan aborted at block %d. Progress=%f\n", | ||||
pindex->nHeight, | |||||
GuessVerificationProgress(chainParams.TxData(), pindex)); | GuessVerificationProgress(chainParams.TxData(), pindex)); | ||||
} | } | ||||
// Hide progress dialog in GUI. | // Hide progress dialog in GUI. | ||||
ShowProgress(_("Rescanning..."), 100); | ShowProgress(_("Rescanning..."), 100); | ||||
fScanningWallet = false; | fScanningWallet = false; | ||||
} | |||||
return ret; | return ret; | ||||
} | } | ||||
void CWallet::ReacceptWalletTransactions() { | void CWallet::ReacceptWalletTransactions() { | ||||
// If transactions aren't being broadcasted, don't let them into local | // If transactions aren't being broadcasted, don't let them into local | ||||
// mempool either. | // mempool either. | ||||
if (!fBroadcastTransactions) { | if (!fBroadcastTransactions) { | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 2,679 Lines • Show Last 20 Lines |