mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
[RPC] Add an uptime command that displays the amount of time that bitcoind has been running
This commit is contained in:
@@ -258,6 +258,22 @@ UniValue stop(const JSONRPCRequest& jsonRequest)
|
||||
return "Bitcoin server stopping";
|
||||
}
|
||||
|
||||
UniValue uptime(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
|
||||
*/
|
||||
@@ -267,6 +283,7 @@ static const CRPCCommand vRPCCommands[] =
|
||||
/* Overall control/query calls */
|
||||
{ "control", "help", &help, true, {"command"} },
|
||||
{ "control", "stop", &stop, true, {} },
|
||||
{ "control", "uptime", &uptime, true, {} },
|
||||
};
|
||||
|
||||
CRPCTable::CRPCTable()
|
||||
|
||||
Reference in New Issue
Block a user