Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/server.cpp
Show First 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | if (jsonRequest.fHelp || jsonRequest.params.size() > 1) | ||||
throw std::runtime_error("stop\n" | throw std::runtime_error("stop\n" | ||||
"\nStop Bitcoin server."); | "\nStop Bitcoin server."); | ||||
// 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(); | ||||
return "Bitcoin server stopping"; | return "Bitcoin server stopping"; | ||||
} | } | ||||
static UniValue uptime(const Config &config, | |||||
const JSONRPCRequest &jsonRequest) { | |||||
if (jsonRequest.fHelp || jsonRequest.params.size() > 1) { | |||||
throw std::runtime_error("uptime\n" | |||||
"\nReturns the total uptime of the server.\n" | |||||
"\nResult:\n" | |||||
"ttt (numeric) The number of seconds " | |||||
"that the server has been running\n" | |||||
"\nExamples:\n" + | |||||
HelpExampleCli("uptime", "") + | |||||
HelpExampleRpc("uptime", "")); | |||||
} | |||||
return GetTime() - GetStartupTime(); | |||||
} | |||||
/** | /** | ||||
* Call Table | * Call Table | ||||
*/ | */ | ||||
// clang-format off | // clang-format off | ||||
static const CRPCCommand vRPCCommands[] = { | static const CRPCCommand vRPCCommands[] = { | ||||
// category name actor (function) okSafe argNames | // category name actor (function) okSafe argNames | ||||
// ------------------- ------------------------ ---------------------- ------ ---------- | // ------------------- ------------------------ ---------------------- ------ ---------- | ||||
/* Overall control/query calls */ | /* Overall control/query calls */ | ||||
{ "control", "help", help, true, {"command"} }, | { "control", "help", help, true, {"command"} }, | ||||
{ "control", "stop", stop, true, {} }, | { "control", "stop", stop, true, {} }, | ||||
{ "control", "uptime", uptime, true, {} }, | |||||
}; | }; | ||||
// clang-format on | // clang-format on | ||||
CRPCTable::CRPCTable() { | CRPCTable::CRPCTable() { | ||||
unsigned int vcidx; | unsigned int vcidx; | ||||
for (vcidx = 0; vcidx < (sizeof(vRPCCommands) / sizeof(vRPCCommands[0])); | for (vcidx = 0; vcidx < (sizeof(vRPCCommands) / sizeof(vRPCCommands[0])); | ||||
vcidx++) { | vcidx++) { | ||||
const CRPCCommand *pcmd; | const CRPCCommand *pcmd; | ||||
▲ Show 20 Lines • Show All 253 Lines • Show Last 20 Lines |