@@ -787,10 +787,7 @@ static RPCHelpMan getblockfrompeer()
787787 {" blockhash" , RPCArg::Type::STR_HEX, RPCArg::Optional::NO, " The block hash" },
788788 {" nodeid" , RPCArg::Type::NUM, RPCArg::Optional::NO, " The node ID (see getpeerinfo for node IDs)" },
789789 },
790- RPCResult{RPCResult::Type::OBJ, " " , " " ,
791- {
792- {RPCResult::Type::STR, " warnings" , /* optional=*/ true , " any warnings" },
793- }},
790+ RPCResult{RPCResult::Type::OBJ_EMPTY, " " , /* optional=*/ false , " " , {}},
794791 RPCExamples{
795792 HelpExampleCli (" getblockfrompeer" , " \" 00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" 0" )
796793 + HelpExampleRpc (" getblockfrompeer" , " \" 00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" 0" )
@@ -816,14 +813,14 @@ static RPCHelpMan getblockfrompeer()
816813 throw JSONRPCError (RPC_MISC_ERROR, " Block header missing" );
817814 }
818815
819- UniValue result = UniValue::VOBJ;
820-
821816 if (index->nStatus & BLOCK_HAVE_DATA) {
822- result.pushKV (" warnings" , " Block already downloaded" );
823- } else if (!peerman.FetchBlock (nodeid, *index)) {
817+ throw JSONRPCError (RPC_MISC_ERROR, " Block already downloaded" );
818+ }
819+
820+ if (!peerman.FetchBlock (nodeid, *index)) {
824821 throw JSONRPCError (RPC_MISC_ERROR, " Failed to fetch block from peer" );
825822 }
826- return result ;
823+ return UniValue::VOBJ ;
827824},
828825 };
829826}
0 commit comments