Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/server.cpp
Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | static UniValue help(Config &config, const JSONRPCRequest &jsonRequest) { | ||||
if (jsonRequest.fHelp || jsonRequest.params.size() > 1) { | if (jsonRequest.fHelp || jsonRequest.params.size() > 1) { | ||||
throw std::runtime_error(RPCHelpMan{ | throw std::runtime_error(RPCHelpMan{ | ||||
"help", | "help", | ||||
"List all commands, or get help for a specified command.\n", | "List all commands, or get help for a specified command.\n", | ||||
{ | { | ||||
{"command", RPCArg::Type::STR, /* default */ "all commands", | {"command", RPCArg::Type::STR, /* default */ "all commands", | ||||
"The command to get help on"}, | "The command to get help on"}, | ||||
}, | }, | ||||
RPCResult{"\"text\" (string) The help text\n"}, | RPCResult{RPCResult::Type::STR, "", "The help text"}, | ||||
RPCExamples{""}, | RPCExamples{""}, | ||||
} | } | ||||
.ToString()); | .ToString()); | ||||
} | } | ||||
std::string strCommand; | std::string strCommand; | ||||
if (jsonRequest.params.size() > 0) { | if (jsonRequest.params.size() > 0) { | ||||
strCommand = jsonRequest.params[0].get_str(); | strCommand = jsonRequest.params[0].get_str(); | ||||
Show All 28 Lines | static UniValue stop(const Config &config, const JSONRPCRequest &jsonRequest) { | ||||
return PACKAGE_NAME " stopping"; | return PACKAGE_NAME " stopping"; | ||||
} | } | ||||
static UniValue uptime(const Config &config, const JSONRPCRequest &request) { | static UniValue uptime(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"uptime", | "uptime", | ||||
"Returns the total uptime of the server.\n", | "Returns the total uptime of the server.\n", | ||||
{}, | {}, | ||||
RPCResult{"ttt (numeric) The number of seconds that the server " | RPCResult{RPCResult::Type::NUM, "", | ||||
"has been running\n"}, | "The number of seconds that the server has been running"}, | ||||
RPCExamples{HelpExampleCli("uptime", "") + | RPCExamples{HelpExampleCli("uptime", "") + | ||||
HelpExampleRpc("uptime", "")}, | HelpExampleRpc("uptime", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
return GetTime() - GetStartupTime(); | return GetTime() - GetStartupTime(); | ||||
} | } | ||||
static UniValue getrpcinfo(const Config &config, | static UniValue getrpcinfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getrpcinfo", | "getrpcinfo", | ||||
"Returns details of the RPC server.\n", | "Returns details of the RPC server.\n", | ||||
{}, | {}, | ||||
RPCResult{ | RPCResult{RPCResult::Type::OBJ, | ||||
"{\n" | "", | ||||
" \"active_commands\" (array) All active commands\n" | "", | ||||
" [\n" | { | ||||
" { (object) Information about an active command\n" | {RPCResult::Type::ARR, | ||||
" \"method\" (string) The name of the RPC command \n" | "active_commands", | ||||
" \"duration\" (numeric) The running time in microseconds\n" | "All active commands", | ||||
" },...\n" | { | ||||
" ],\n" | {RPCResult::Type::OBJ, | ||||
" \"logpath\": \"xxx\" (string) The complete file path to the " | "", | ||||
"debug log\n" | "Information about an active command", | ||||
"}\n"}, | { | ||||
{RPCResult::Type::STR, "method", | |||||
"The name of the RPC command"}, | |||||
{RPCResult::Type::NUM, "duration", | |||||
"The running time in microseconds"}, | |||||
}}, | |||||
}}, | |||||
{RPCResult::Type::STR, "logpath", | |||||
"The complete file path to the debug log"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("getrpcinfo", "") + | RPCExamples{HelpExampleCli("getrpcinfo", "") + | ||||
HelpExampleRpc("getrpcinfo", "")}, | HelpExampleRpc("getrpcinfo", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(g_rpc_server_info.mutex); | LOCK(g_rpc_server_info.mutex); | ||||
UniValue active_commands(UniValue::VARR); | UniValue active_commands(UniValue::VARR); | ||||
for (const RPCCommandExecutionInfo &info : | for (const RPCCommandExecutionInfo &info : | ||||
▲ Show 20 Lines • Show All 281 Lines • Show Last 20 Lines |