@@ -2869,6 +2869,45 @@ return RPCHelpMan{
28692869 };
28702870}
28712871
2872+ static RPCHelpMan getblockfileinfo ()
2873+ {
2874+ return RPCHelpMan{
2875+ " getblockfileinfo" ,
2876+ " Retrieves information about a certain block file." ,
2877+ {
2878+ {" file_number" , RPCArg::Type::NUM, RPCArg::Optional::NO, " block file number" },
2879+ },
2880+ RPCResult{
2881+ RPCResult::Type::OBJ, " " , " " ,
2882+ {
2883+ {RPCResult::Type::NUM, " blocks_num" , " the number of blocks stored in the file" },
2884+ {RPCResult::Type::NUM, " lowest_block" , " the height of the lowest block inside the file" },
2885+ {RPCResult::Type::NUM, " highest_block" , " the height of the highest block inside the file" },
2886+ {RPCResult::Type::NUM, " data_size" , " the number of used bytes in the block file" },
2887+ {RPCResult::Type::NUM, " undo_size" , " the number of used bytes in the undo file" },
2888+ }
2889+ },
2890+ RPCExamples{ HelpExampleCli (" getblockfileinfo" , " 0" ) },
2891+ [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
2892+ NodeContext& node = EnsureAnyNodeContext (request.context );
2893+
2894+ int block_num = request.params [0 ].getInt <int >();
2895+ if (block_num < 0 ) throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid block number" );
2896+
2897+ CBlockFileInfo* info = node.chainman ->m_blockman .GetBlockFileInfo (block_num);
2898+ if (!info) throw JSONRPCError (RPC_INVALID_PARAMETER, " block file not found" );
2899+
2900+ UniValue result (UniValue::VOBJ);
2901+ result.pushKV (" blocks_num" , info->nBlocks );
2902+ result.pushKV (" lowest_block" , info->nHeightFirst );
2903+ result.pushKV (" highest_block" , info->nHeightLast );
2904+ result.pushKV (" data_size" , info->nSize );
2905+ result.pushKV (" undo_size" , info->nUndoSize );
2906+
2907+ return result;
2908+ }
2909+ };
2910+ }
28722911
28732912void RegisterBlockchainRPCCommands (CRPCTable& t)
28742913{
@@ -2896,6 +2935,7 @@ void RegisterBlockchainRPCCommands(CRPCTable& t)
28962935 {" blockchain" , &dumptxoutset},
28972936 {" blockchain" , &loadtxoutset},
28982937 {" blockchain" , &getchainstates},
2938+ {" hidden" , &getblockfileinfo},
28992939 {" hidden" , &invalidateblock},
29002940 {" hidden" , &reconsiderblock},
29012941 {" hidden" , &waitfornewblock},
0 commit comments