Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/server.cpp
Show First 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | std::string CRPCTable::help(Config &config, const std::string &strCommand, | ||||
strRet = strRet.substr(0, strRet.size() - 1); | strRet = strRet.substr(0, strRet.size() - 1); | ||||
return strRet; | return strRet; | ||||
} | } | ||||
static UniValue help(Config &config, const JSONRPCRequest &jsonRequest) { | 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", | ||||
"\nList 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{"\"text\" (string) The help text\n"}, | ||||
RPCExamples{""}, | RPCExamples{""}, | ||||
} | } | ||||
.ToString()); | .ToString()); | ||||
Show All 10 Lines | |||||
static UniValue stop(const Config &config, const JSONRPCRequest &jsonRequest) { | static UniValue stop(const Config &config, const JSONRPCRequest &jsonRequest) { | ||||
// Accept the deprecated and ignored 'detach' boolean argument | // Accept the deprecated and ignored 'detach' boolean argument | ||||
// Also accept the hidden 'wait' integer argument (milliseconds) | // Also accept the hidden 'wait' integer argument (milliseconds) | ||||
// For instance, 'stop 1000' makes the call wait 1 second before returning | // For instance, 'stop 1000' makes the call wait 1 second before returning | ||||
// to the client (intended for testing) | // to the client (intended for testing) | ||||
if (jsonRequest.fHelp || jsonRequest.params.size() > 1) { | if (jsonRequest.fHelp || jsonRequest.params.size() > 1) { | ||||
throw std::runtime_error(RPCHelpMan{ | throw std::runtime_error(RPCHelpMan{ | ||||
"stop", | "stop", | ||||
"\nStop Bitcoin server.", | "Stop Bitcoin server.", | ||||
{}, | {}, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{""}, | RPCExamples{""}, | ||||
} | } | ||||
.ToString()); | .ToString()); | ||||
} | } | ||||
// Event loop will exit after current HTTP requests have been handled, so | // Event loop will exit after current HTTP requests have been handled, so | ||||
// this reply will get back to the client. | // this reply will get back to the client. | ||||
StartShutdown(); | StartShutdown(); | ||||
if (jsonRequest.params[0].isNum()) { | if (jsonRequest.params[0].isNum()) { | ||||
UninterruptibleSleep( | UninterruptibleSleep( | ||||
std::chrono::milliseconds{jsonRequest.params[0].get_int()}); | std::chrono::milliseconds{jsonRequest.params[0].get_int()}); | ||||
} | } | ||||
return "Bitcoin server stopping"; | return "Bitcoin server stopping"; | ||||
} | } | ||||
static UniValue uptime(const Config &config, const JSONRPCRequest &request) { | static UniValue uptime(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"uptime", | "uptime", | ||||
"\nReturns 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{"ttt (numeric) The number of seconds that the server " | ||||
"has been running\n"}, | "has been running\n"}, | ||||
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", | ||||
"\nReturns details of the RPC server.\n", | "Returns details of the RPC server.\n", | ||||
{}, | {}, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{""}, | RPCExamples{""}, | ||||
} | } | ||||
.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); | ||||
▲ Show 20 Lines • Show All 278 Lines • Show Last 20 Lines |