Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/server.cpp
Show First 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | static UniValue help(Config &config, const JSONRPCRequest &jsonRequest) { | ||||
if (jsonRequest.params.size() > 0) { | if (jsonRequest.params.size() > 0) { | ||||
strCommand = jsonRequest.params[0].get_str(); | strCommand = jsonRequest.params[0].get_str(); | ||||
} | } | ||||
return tableRPC.help(config, strCommand, jsonRequest); | return tableRPC.help(config, strCommand, jsonRequest); | ||||
} | } | ||||
static UniValue stop(const Config &config, const JSONRPCRequest &jsonRequest) { | static UniValue stop(const Config &config, const JSONRPCRequest &jsonRequest) { | ||||
static const std::string RESULT{PACKAGE_NAME " stopping"}; | |||||
// 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", | ||||
"\nRequest a graceful shutdown of " PACKAGE_NAME ".", | "\nRequest a graceful shutdown of " PACKAGE_NAME ".", | ||||
{}, | {}, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::STR, "", | ||||
"A string with the content '" + RESULT + "'"}, | |||||
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 PACKAGE_NAME " stopping"; | return RESULT; | ||||
} | } | ||||
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{RPCResult::Type::NUM, "", | RPCResult{RPCResult::Type::NUM, "", | ||||
▲ Show 20 Lines • Show All 332 Lines • Show Last 20 Lines |