diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-06-27 11:33:32 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-06-27 11:34:15 +0200 |
commit | 1680ee0edf46aa22c4d00c8ff4f3d0bcc235bc68 (patch) | |
tree | 81a3e57d6a9c6870b5436283a0276d86e751c484 /src/rpc | |
parent | 78783531b7cc90c6f405dd9c62807be835d4c74f (diff) | |
parent | c07475294ae2c60f1dcc394922838b1f1f57b476 (diff) | |
download | bitcoin-1680ee0edf46aa22c4d00c8ff4f3d0bcc235bc68.tar.xz |
Merge #10400: [RPC] Add an uptime command that displays the amount of time (in seconds) bitcoind has been running
c074752 [RPC] Add an uptime command that displays the amount of time that bitcoind has been running (Ricardo Velhote)
Tree-SHA512: 8f59d4205042885f23f5b87a0eae0f5d386e9c6134e5324598e7ee304728d4275f383cd154bf1fb25350f5a88cc0ed9f97edb099e9b50c4a0ba72d63ec5ca5b4
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/server.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 1a04ce2b47..c320d20453 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -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() |