@@ -2321,6 +2321,7 @@ static RPCHelpMan scanblocks()
23212321 {RPCResult::Type::ARR, " relevant_blocks" , " Blocks that may have matched a scanobject." , {
23222322 {RPCResult::Type::STR_HEX, " blockhash" , " A relevant blockhash" },
23232323 }},
2324+ {RPCResult::Type::BOOL, " completed" , " true if the scan process was not aborted" }
23242325 }},
23252326 RPCResult{" when action=='status' and a scan is currently in progress" , RPCResult::Type::OBJ, " " , " " , {
23262327 {RPCResult::Type::NUM, " progress" , " Approximate percent complete" },
@@ -2358,8 +2359,7 @@ static RPCHelpMan scanblocks()
23582359 // set the abort flag
23592360 g_scanfilter_should_abort_scan = true ;
23602361 return true ;
2361- }
2362- else if (request.params [0 ].get_str () == " start" ) {
2362+ } else if (request.params [0 ].get_str () == " start" ) {
23632363 BlockFiltersScanReserver reserver;
23642364 if (!reserver.reserve ()) {
23652365 throw JSONRPCError (RPC_INVALID_PARAMETER, " Scan already in progress, use action \" abort\" or \" status\" " );
@@ -2424,12 +2424,13 @@ static RPCHelpMan scanblocks()
24242424 g_scanfilter_should_abort_scan = false ;
24252425 g_scanfilter_progress = 0 ;
24262426 g_scanfilter_progress_height = start_block_height;
2427+ bool completed = true ;
24272428
24282429 const CBlockIndex* end_range = nullptr ;
24292430 do {
24302431 node.rpc_interruption_point (); // allow a clean shutdown
24312432 if (g_scanfilter_should_abort_scan) {
2432- LogPrintf ( " scanblocks RPC aborted at height %d. \n " , end_range-> nHeight ) ;
2433+ completed = false ;
24332434 break ;
24342435 }
24352436
@@ -2453,7 +2454,6 @@ static RPCHelpMan scanblocks()
24532454 }
24542455
24552456 blocks.push_back (filter.GetBlockHash ().GetHex ());
2456- LogPrint (BCLog::RPC, " scanblocks: found match in %s\n " , filter.GetBlockHash ().GetHex ());
24572457 }
24582458 }
24592459 }
@@ -2472,8 +2472,9 @@ static RPCHelpMan scanblocks()
24722472 } while (start_index != stop_block);
24732473
24742474 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
24762476 ret.pushKV (" relevant_blocks" , blocks);
2477+ ret.pushKV (" completed" , completed);
24772478 }
24782479 else {
24792480 throw JSONRPCError (RPC_INVALID_PARAMETER, strprintf (" Invalid action '%s'" , request.params [0 ].get_str ()));
0 commit comments