Skip to content

Commit c4fda76

Browse files
committed
wallet: Interrupt rescan on shutdown request
1 parent 0bc980b commit c4fda76

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/wallet/wallet.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <consensus/consensus.h>
1212
#include <consensus/validation.h>
1313
#include <fs.h>
14+
#include <init.h>
1415
#include <key.h>
1516
#include <key_io.h>
1617
#include <keystore.h>
@@ -1753,7 +1754,7 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
17531754
dProgressTip = GuessVerificationProgress(chainParams.TxData(), tip);
17541755
}
17551756
double gvp = dProgressStart;
1756-
while (pindex && !fAbortRescan)
1757+
while (pindex && !fAbortRescan && !ShutdownRequested())
17571758
{
17581759
if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0) {
17591760
ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((gvp - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
@@ -1794,6 +1795,8 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
17941795
}
17951796
if (pindex && fAbortRescan) {
17961797
LogPrintf("Rescan aborted at block %d. Progress=%f\n", pindex->nHeight, gvp);
1798+
} else if (pindex && ShutdownRequested()) {
1799+
LogPrintf("Rescan interrupted by shutdown request at block %d. Progress=%f\n", pindex->nHeight, gvp);
17971800
}
17981801
ShowProgress(_("Rescanning..."), 100); // hide progress dialog in GUI
17991802
}

0 commit comments

Comments
 (0)