mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Track uptime. Update local fee schedule based on load manager.
This commit is contained in:
@@ -1786,6 +1786,21 @@ Json::Value RPCHandler::doLogin(Json::Value jvRequest)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void textTime(std::string& text, int& seconds, const char *unitName, int unitVal)
|
||||
{
|
||||
int i = seconds / unitVal;
|
||||
if (i == 0)
|
||||
return;
|
||||
seconds -= unitVal * i;
|
||||
if (!text.empty())
|
||||
text += ", ";
|
||||
text += boost::lexical_cast<std::string>(i);
|
||||
text += " ";
|
||||
text += unitName;
|
||||
if (i > 1)
|
||||
text += "s";
|
||||
}
|
||||
|
||||
// {
|
||||
// min_count: <number> // optional, defaults to 10
|
||||
// }
|
||||
@@ -1807,6 +1822,15 @@ Json::Value RPCHandler::doGetCounts(Json::Value jvRequest)
|
||||
if (dbKB > 0)
|
||||
ret["dbKB"] = dbKB;
|
||||
|
||||
std::string uptime;
|
||||
int s = theApp->getLoadManager().getUptime();
|
||||
textTime(uptime, s, "year", 365*24*60*60);
|
||||
textTime(uptime, s, "day", 24*60*60);
|
||||
textTime(uptime, s, "hour", 24*60);
|
||||
textTime(uptime, s, "minute", 60);
|
||||
textTime(uptime, s, "second", 1);
|
||||
ret["uptime"] = uptime;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user