Merge #13076: Fix ScanForWalletTransactions to return an enum indicating scan result: success / failure / user_abort
bd3b0361dAdd stop_block out arg to ScanForWalletTransactions (Ben Woosley)3002d6cf3Return a status enum from ScanForWalletTransactions (Ben Woosley)bb24d6865Make CWallet::ScanForWalletTransactions args and return value const (Ben Woosley) Pull request description: Return the failed block as an out arg. Fixes #11450. /cc #12275 Tree-SHA512: 6a523e5425ebfe24e664a942ae21c797ccc1281c25b1bf8d02ad95c19dae343fd8051985ef11853474de7628fd6bed5f15190fbc087c3466ce6fdecab37d72a9
This commit is contained in:
@@ -3422,16 +3422,17 @@ UniValue rescanblockchain(const JSONRPCRequest& request)
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
stopBlock = pindexStop ? pindexStop : pChainTip;
|
||||
}
|
||||
else {
|
||||
const CBlockIndex *failed_block, *stopBlock;
|
||||
CWallet::ScanResult result =
|
||||
pwallet->ScanForWalletTransactions(pindexStart, pindexStop, reserver, failed_block, stopBlock, true);
|
||||
switch (result) {
|
||||
case CWallet::ScanResult::SUCCESS:
|
||||
break; // stopBlock set by ScanForWalletTransactions
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user