diff options
author | Ben Woosley <ben.woosley@gmail.com> | 2018-04-29 15:45:44 +0000 |
---|---|---|
committer | Ben Woosley <ben.woosley@gmail.com> | 2018-11-13 00:04:13 -0500 |
commit | 3002d6cf31821622e9f21d51e536cafc5cfb10ae (patch) | |
tree | a0831d207b5ca61d08285ac71212929817e5d8d4 /src/wallet/rpcwallet.cpp | |
parent | bb24d686500375564a2137f0940b329b6905bce6 (diff) | |
download | bitcoin-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.cpp | 18 |
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); |