Skip to content

Commit

Permalink
Add RPC command uptime
Browse files Browse the repository at this point in the history
- Used to track how long your QT or core wallet has been running
  • Loading branch information
kiirodev committed Nov 3, 2023
1 parent e9c58fc commit 592a15d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ static const CRPCCommand vRPCCommands[] =
/* Overall control/query calls */
{ "control", "help", &help, true },
{ "control", "stop", &stop, true },
{ "control", "uptime", &uptime, true },
/* Address index */
{ "addressindex", "getaddressmempool", &getaddressmempool, true },
{ "addressindex", "getaddressutxos", &getaddressutxos, false },
Expand Down
3 changes: 3 additions & 0 deletions src/rpc/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ extern UniValue znodelist(const JSONRPCRequest &request);
extern UniValue znodebroadcast(const JSONRPCRequest &request);
extern UniValue znsync(const JSONRPCRequest &request);

extern UniValue uptime(const JSONRPCRequest &request);


bool StartRPC();
void InterruptRPC();
void StopRPC();
Expand Down
9 changes: 9 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ bool fMasternodeMode = false;
bool fLiteMode = false;
int nWalletBackups = 10;

// Application startup time (used for uptime calculation)
const int64_t nStartupTime = GetTime();

const char * const BITCOIN_CONF_FILENAME = "kiirocoin.conf";
const char * const BITCOIN_PID_FILENAME = "kiirocoind.pid";

Expand Down Expand Up @@ -1036,3 +1039,9 @@ std::string CopyrightHolders(const std::string& strPrefix)

return strCopyrightHolders;
}

// Obtain the application startup time (used for uptime calculation)
int64_t GetStartupTime()
{
return nStartupTime;
}
3 changes: 3 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ inline int64_t roundint64(double d)
return (int64_t)(d > 0 ? d + 0.5 : d - 0.5);
}

// Application startup time (used for uptime calculation)
int64_t GetStartupTime();

void SetupEnvironment();
bool SetupNetworking();

Expand Down

0 comments on commit 592a15d

Please sign in to comment.