aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/rpcwallet.cpp
diff options
context:
space:
mode:
authorBen Woosley <ben.woosley@gmail.com>2018-04-29 15:45:44 +0000
committerBen Woosley <ben.woosley@gmail.com>2018-11-13 00:04:13 -0500
commit3002d6cf31821622e9f21d51e536cafc5cfb10ae (patch)
treea0831d207b5ca61d08285ac71212929817e5d8d4 /src/wallet/rpcwallet.cpp
parentbb24d686500375564a2137f0940b329b6905bce6 (diff)
downloadbitcoin-3002d6cf31821622e9f21d51e536cafc5cfb10ae.tar.xz
Return a status enum from ScanForWalletTransactions
Return the failed block as an out var. This clarifies the outcome as the prior return value could be null due to user abort or failure.
Diffstat (limited to 'src/wallet/rpcwallet.cpp')
-rw-r--r--src/wallet/rpcwallet.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 1514c978b8..c3f12f373d 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -3332,16 +3332,18 @@ UniValue rescanblockchain(const JSONRPCRequest& request)
}
}
- const CBlockIndex* stopBlock = pwallet->ScanForWalletTransactions(pindexStart, pindexStop, reserver, true);
- if (!stopBlock) {
- if (pwallet->IsAbortingRescan()) {
- throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted.");
- }
- // if we got a nullptr returned, ScanForWalletTransactions did rescan up to the requested stopindex
+ const CBlockIndex* stopBlock;
+ CWallet::ScanResult result =
+ pwallet->ScanForWalletTransactions(pindexStart, pindexStop, reserver, stopBlock, true);
+ switch (result) {
+ case CWallet::ScanResult::SUCCESS:
stopBlock = pindexStop ? pindexStop : pChainTip;
- }
- else {
+ break;
+ case CWallet::ScanResult::FAILURE:
throw JSONRPCError(RPC_MISC_ERROR, "Rescan failed. Potentially corrupted data files.");
+ case CWallet::ScanResult::USER_ABORT:
+ throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted.");
+ // no default case, so the compiler can warn about missing cases
}
UniValue response(UniValue::VOBJ);
response.pushKV("start_height", pindexStart->nHeight);