@@ -283,11 +283,37 @@ static UniValue uptime(const JSONRPCRequest& jsonRequest)
283
283
return GetTime () - GetStartupTime ();
284
284
}
285
285
286
+ static UniValue getrpcinfo (const JSONRPCRequest& request)
287
+ {
288
+ if (request.fHelp || request.params .size () > 0 ) {
289
+ throw std::runtime_error (
290
+ RPCHelpMan{" getrpcinfo" ,
291
+ " \n Returns details of the RPC server.\n " , {}}
292
+ .ToString ()
293
+ );
294
+ }
295
+
296
+ LOCK (g_rpc_server_info.mutex );
297
+ UniValue active_commands (UniValue::VARR);
298
+ for (const RPCCommandExecutionInfo& info : g_rpc_server_info.active_commands ) {
299
+ UniValue entry (UniValue::VOBJ);
300
+ entry.pushKV (" method" , info.method );
301
+ entry.pushKV (" duration" , GetTimeMicros () - info.start );
302
+ active_commands.push_back (entry);
303
+ }
304
+
305
+ UniValue result (UniValue::VOBJ);
306
+ result.pushKV (" active_commands" , active_commands);
307
+
308
+ return result;
309
+ }
310
+
286
311
// clang-format off
287
312
static const CRPCCommand vRPCCommands[] =
288
313
{ // category name actor (function) argNames
289
314
// --------------------- ------------------------ ----------------------- ----------
290
315
/* Overall control/query calls */
316
+ { " control" , " getrpcinfo" , &getrpcinfo, {} },
291
317
{ " control" , " help" , &help, {" command" } },
292
318
{ " control" , " stop" , &stop, {" wait" } },
293
319
{ " control" , " uptime" , &uptime, {} },
0 commit comments