@@ -2321,6 +2321,7 @@ static RPCHelpMan scanblocks()
2321
2321
{RPCResult::Type::ARR, " relevant_blocks" , " Blocks that may have matched a scanobject." , {
2322
2322
{RPCResult::Type::STR_HEX, " blockhash" , " A relevant blockhash" },
2323
2323
}},
2324
+ {RPCResult::Type::BOOL, " completed" , " true if the scan process was not aborted" }
2324
2325
}},
2325
2326
RPCResult{" when action=='status' and a scan is currently in progress" , RPCResult::Type::OBJ, " " , " " , {
2326
2327
{RPCResult::Type::NUM, " progress" , " Approximate percent complete" },
@@ -2358,8 +2359,7 @@ static RPCHelpMan scanblocks()
2358
2359
// set the abort flag
2359
2360
g_scanfilter_should_abort_scan = true ;
2360
2361
return true ;
2361
- }
2362
- else if (request.params [0 ].get_str () == " start" ) {
2362
+ } else if (request.params [0 ].get_str () == " start" ) {
2363
2363
BlockFiltersScanReserver reserver;
2364
2364
if (!reserver.reserve ()) {
2365
2365
throw JSONRPCError (RPC_INVALID_PARAMETER, " Scan already in progress, use action \" abort\" or \" status\" " );
@@ -2424,12 +2424,13 @@ static RPCHelpMan scanblocks()
2424
2424
g_scanfilter_should_abort_scan = false ;
2425
2425
g_scanfilter_progress = 0 ;
2426
2426
g_scanfilter_progress_height = start_block_height;
2427
+ bool completed = true ;
2427
2428
2428
2429
const CBlockIndex* end_range = nullptr ;
2429
2430
do {
2430
2431
node.rpc_interruption_point (); // allow a clean shutdown
2431
2432
if (g_scanfilter_should_abort_scan) {
2432
- LogPrintf ( " scanblocks RPC aborted at height %d. \n " , end_range-> nHeight ) ;
2433
+ completed = false ;
2433
2434
break ;
2434
2435
}
2435
2436
@@ -2453,7 +2454,6 @@ static RPCHelpMan scanblocks()
2453
2454
}
2454
2455
2455
2456
blocks.push_back (filter.GetBlockHash ().GetHex ());
2456
- LogPrint (BCLog::RPC, " scanblocks: found match in %s\n " , filter.GetBlockHash ().GetHex ());
2457
2457
}
2458
2458
}
2459
2459
}
@@ -2472,8 +2472,9 @@ static RPCHelpMan scanblocks()
2472
2472
} while (start_index != stop_block);
2473
2473
2474
2474
ret.pushKV (" from_height" , start_block_height);
2475
- ret.pushKV (" to_height" , stop_block ->nHeight );
2475
+ ret.pushKV (" to_height" , start_index ->nHeight ); // start_index is always the last scanned block here
2476
2476
ret.pushKV (" relevant_blocks" , blocks);
2477
+ ret.pushKV (" completed" , completed);
2477
2478
}
2478
2479
else {
2479
2480
throw JSONRPCError (RPC_INVALID_PARAMETER, strprintf (" Invalid action '%s'" , request.params [0 ].get_str ()));
0 commit comments