Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
jed
2013-02-06 09:05:43 -08:00
15 changed files with 190 additions and 38 deletions

View File

@@ -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 = upTime();
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;
}