aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-05-03 11:25:43 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2018-05-03 11:27:36 +0200
commit2afdc294039fc99f098b11b8883c1d530004a66d (patch)
treef55ffa749d05ac9e2ab9cdbf0f6e7696053a2bdc /src
parentef006d92845a78db0928607c6c11d30962f55f85 (diff)
parentc4fda7672a975acc1a8c0faa559af0dcc223b95e (diff)
Merge #12507: Interrupt rescan on shutdown request
c4fda76 wallet: Interrupt rescan on shutdown request (João Barbosa) Pull request description: Fixes #10987. Here are the steps to test the feature: 1. start bitcoind, generate a couple of transactions and then stop: ``` bitcoind -regtest -printtoconsole bitcoin-cli -regtest generate 100 ``` 2. apply the following patch ```diff diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 2478d67ce..8f8cea40c 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1671,6 +1671,7 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock } while (pindex && !fAbortRescan && !ShutdownRequested()) { + MilliSleep(500); if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0) { double gvp = 0; { ``` 3. start bitcoind with rescan flag, interrupt with CTRL+C and the output should look like: ``` bitcoind -regtest -printtoconsole -rescan ... ^C2018-02-22 01:00:55 AddToWallet e8bfb4501b630ad2acb91e88ab0112a779766536d2c564b04faae45ae90e18f7 2018-02-22 01:00:55 Rescan interrupted by shutdown request at block 5. Progress=1.000000 2018-02-22 01:00:55 rescan 1774ms 2018-02-22 01:00:55 setKeyPool.size() = 1995 2018-02-22 01:00:55 mapWallet.size() = 10145 2018-02-22 01:00:55 mapAddressBook.size() = 3 2018-02-22 01:00:55 Shutdown: In progress... 2018-02-22 01:00:55 scheduler thread interrupt 2018-02-22 01:00:55 Shutdown: done ``` Tree-SHA512: f9bebe2cdacf0359b6cbfcbc48ac2818a3ae7aa7822ff0c2c0de4ca2fff7c88493380b74a1c5ff2ce1de01fe605b0e5ef3576f124ea9cff8ef25a9e762477b92
Diffstat (limited to 'src')
-rw-r--r--src/wallet/wallet.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index c0aa748073..eeab05fd0f 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -11,6 +11,7 @@
#include <consensus/consensus.h>
#include <consensus/validation.h>
#include <fs.h>
+#include <init.h>
#include <key.h>
#include <key_io.h>
#include <keystore.h>
@@ -1753,7 +1754,7 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
dProgressTip = GuessVerificationProgress(chainParams.TxData(), tip);
}
double gvp = dProgressStart;
- while (pindex && !fAbortRescan)
+ while (pindex && !fAbortRescan && !ShutdownRequested())
{
if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0) {
ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((gvp - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
@@ -1794,6 +1795,8 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
}
if (pindex && fAbortRescan) {
LogPrintf("Rescan aborted at block %d. Progress=%f\n", pindex->nHeight, gvp);
+ } else if (pindex && ShutdownRequested()) {
+ LogPrintf("Rescan interrupted by shutdown request at block %d. Progress=%f\n", pindex->nHeight, gvp);
}
ShowProgress(_("Rescanning..."), 100); // hide progress dialog in GUI
}