Merge pull request #6374 from nuttycom/bug/wallet_rescan_escape
Allow rescan to exit in the case that Ctrl-C is pressed.
This commit is contained in:
commit
149ffb9582
|
@ -4679,13 +4679,13 @@ void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
|
||||||
* from or to us. If fUpdate is true, found transactions that already
|
* from or to us. If fUpdate is true, found transactions that already
|
||||||
* exist in the wallet will be updated.
|
* exist in the wallet will be updated.
|
||||||
*/
|
*/
|
||||||
int CWallet::ScanForWalletTransactions(
|
std::optional<int> CWallet::ScanForWalletTransactions(
|
||||||
CBlockIndex* pindexStart,
|
CBlockIndex* pindexStart,
|
||||||
bool fUpdate,
|
bool fUpdate,
|
||||||
bool isInitScan)
|
bool isInitScan)
|
||||||
{
|
{
|
||||||
assert(pindexStart != nullptr);
|
assert(pindexStart != nullptr);
|
||||||
int ret = 0;
|
int myTransactionsFound = 0;
|
||||||
int64_t nNow = GetTime();
|
int64_t nNow = GetTime();
|
||||||
const CChainParams& chainParams = Params();
|
const CChainParams& chainParams = Params();
|
||||||
const auto& consensus = chainParams.GetConsensus();
|
const auto& consensus = chainParams.GetConsensus();
|
||||||
|
@ -4756,6 +4756,9 @@ int CWallet::ScanForWalletTransactions(
|
||||||
double dProgressTip = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip(), false);
|
double dProgressTip = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip(), false);
|
||||||
while (pindex)
|
while (pindex)
|
||||||
{
|
{
|
||||||
|
// Allow the rescan to be interrupted on a block boundary.
|
||||||
|
if (ShutdownRequested()) return std::nullopt;
|
||||||
|
|
||||||
if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0)
|
if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0)
|
||||||
ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex, false) - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
|
ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex, false) - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
|
||||||
|
|
||||||
|
@ -4775,7 +4778,7 @@ int CWallet::ScanForWalletTransactions(
|
||||||
{
|
{
|
||||||
if (batchScanner.AddToWalletIfInvolvingMe(consensus, tx, &block, pindex->nHeight, fUpdate)) {
|
if (batchScanner.AddToWalletIfInvolvingMe(consensus, tx, &block, pindex->nHeight, fUpdate)) {
|
||||||
myTxHashes.push_back(tx.GetHash());
|
myTxHashes.push_back(tx.GetHash());
|
||||||
ret++;
|
myTransactionsFound++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4820,7 +4823,7 @@ int CWallet::ScanForWalletTransactions(
|
||||||
|
|
||||||
ShowProgress(_("Rescanning..."), 100); // hide progress dialog in GUI
|
ShowProgress(_("Rescanning..."), 100); // hide progress dialog in GUI
|
||||||
}
|
}
|
||||||
return ret;
|
return myTransactionsFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::ReacceptWalletTransactions()
|
void CWallet::ReacceptWalletTransactions()
|
||||||
|
@ -6810,7 +6813,10 @@ bool CWallet::InitLoadWallet(const CChainParams& params, bool clearWitnessCaches
|
||||||
chainActive.Height() - pindexRescan->nHeight,
|
chainActive.Height() - pindexRescan->nHeight,
|
||||||
pindexRescan->nHeight);
|
pindexRescan->nHeight);
|
||||||
nStart = GetTimeMillis();
|
nStart = GetTimeMillis();
|
||||||
walletInstance->ScanForWalletTransactions(pindexRescan, true, true);
|
if (!walletInstance->ScanForWalletTransactions(pindexRescan, true, true).has_value()) {
|
||||||
|
return UIError(_("CWallet::InitLoadWallet: rescan interrupted due to shutdown request."));
|
||||||
|
}
|
||||||
|
|
||||||
LogPrintf(" rescan %15dms\n", GetTimeMillis() - nStart);
|
LogPrintf(" rescan %15dms\n", GetTimeMillis() - nStart);
|
||||||
walletInstance->SetBestChain(chainActive.GetLocator());
|
walletInstance->SetBestChain(chainActive.GetLocator());
|
||||||
CWalletDB::IncrementUpdateCounter();
|
CWalletDB::IncrementUpdateCounter();
|
||||||
|
|
|
@ -1859,7 +1859,7 @@ public:
|
||||||
std::vector<uint256> commitments,
|
std::vector<uint256> commitments,
|
||||||
std::vector<std::optional<SproutWitness>>& witnesses,
|
std::vector<std::optional<SproutWitness>>& witnesses,
|
||||||
uint256 &final_anchor);
|
uint256 &final_anchor);
|
||||||
int ScanForWalletTransactions(
|
std::optional<int> ScanForWalletTransactions(
|
||||||
CBlockIndex* pindexStart,
|
CBlockIndex* pindexStart,
|
||||||
bool fUpdate,
|
bool fUpdate,
|
||||||
bool isInitScan);
|
bool isInitScan);
|
||||||
|
|
Loading…
Reference in New Issue