Initial implementation of abortrescan
This commit is contained in:
@@ -144,6 +144,36 @@ UniValue convertpassphrase(const UniValue& params, bool fHelp, const CPubKey& my
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue abortrescan(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
|
{
|
||||||
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
|
if (fHelp || params.size() > 0)
|
||||||
|
throw runtime_error(
|
||||||
|
"abortrescan\n"
|
||||||
|
"\nAbort a currently running rescan.\n"
|
||||||
|
"\nUse 'getrescaninfo' to get rescan progress details.\n"
|
||||||
|
"\nReturns true if aborting rescan, false otherwise.\n"
|
||||||
|
"\nArguments: none\n"
|
||||||
|
"\nExamples:\n"
|
||||||
|
"\nAbort rescan :\n"
|
||||||
|
+ HelpExampleCli("abortrescan","")
|
||||||
|
+ "\nAs a JSON-RPC call\n"
|
||||||
|
+ HelpExampleRpc("abortrescan","")
|
||||||
|
);
|
||||||
|
if(!pwalletMain->fRescanning) {
|
||||||
|
LogPrintf("%s: no rescan running\n",__func__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(pwalletMain->IsAbortingRescan()) {
|
||||||
|
LogPrintf("%s: already aborting current rescan\n",__func__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
pwalletMain->AbortRescan();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
UniValue getrescaninfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
UniValue getrescaninfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
|
|||||||
@@ -2778,6 +2778,19 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
|
|||||||
while (pindex)
|
while (pindex)
|
||||||
{
|
{
|
||||||
pwalletMain->rescanHeight = pindex->GetHeight();
|
pwalletMain->rescanHeight = pindex->GetHeight();
|
||||||
|
if(pwalletMain->fAbortRescan) {
|
||||||
|
//TODO: should we update witness caches?
|
||||||
|
LogPrintf("%s: Rescan aborted at block %d\n", pwalletMain->rescanHeight);
|
||||||
|
pwalletMain->fRescanning = false;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (ShutdownRequested()) {
|
||||||
|
//TODO: should we update witness caches?
|
||||||
|
LogPrintf("%s: Rescan interrupted by shutdown request at block %d\n", pwalletMain->rescanHeight);
|
||||||
|
pwalletMain->fRescanning = false;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (pindex->GetHeight() % 100 == 0 && dProgressTip - dProgressStart > 0.0)
|
if (pindex->GetHeight() % 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))));
|
||||||
|
|
||||||
|
|||||||
@@ -807,6 +807,13 @@ public:
|
|||||||
bool fSweepEnabled = false;
|
bool fSweepEnabled = false;
|
||||||
bool fSweepExternalEnabled = false;
|
bool fSweepExternalEnabled = false;
|
||||||
bool fSweepRunning = false;
|
bool fSweepRunning = false;
|
||||||
|
|
||||||
|
std::atomic<bool> fAbortRescan{false};
|
||||||
|
// abort current rescan
|
||||||
|
void AbortRescan() { fAbortRescan = true; }
|
||||||
|
// Are we currently aborting a rescan?
|
||||||
|
bool IsAbortingRescan() const { return fAbortRescan; }
|
||||||
|
|
||||||
// Are we currently rescanning?
|
// Are we currently rescanning?
|
||||||
bool fRescanning = false;
|
bool fRescanning = false;
|
||||||
// Current height of our rescan
|
// Current height of our rescan
|
||||||
|
|||||||
Reference in New Issue
Block a user