Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cfad4ba

Browse files
committedSep 9, 2017
Added uptime to cli
1 parent f4c6f9d commit cfad4ba

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed
 

‎ethminer/MinerAux.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ class MinerCLI
798798
f.resetMiningProgress();
799799
if (current)
800800
{
801-
minelog << mp << f.getSolutionStats();
801+
minelog << mp << f.getSolutionStats() << f.farmLaunchedFormatted();
802802
#if ETH_DBUS
803803
dbusint.send(toString(mp).data());
804804
#endif
@@ -950,7 +950,7 @@ class MinerCLI
950950
{
951951
if (client.current())
952952
{
953-
minelog << mp << f.getSolutionStats();
953+
minelog << mp << f.getSolutionStats() << f.farmLaunchedFormatted();
954954
#if ETH_DBUS
955955
dbusint.send(toString(mp).data());
956956
#endif

‎libapicore/ApiServer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void ApiServer::getMinerStat1(const Json::Value& request, Json::Value& response)
1414
{
1515
(void) request; // unused
1616

17-
auto runningTime = std::chrono::duration_cast<std::chrono::minutes>(steady_clock::now() - this->m_started);
17+
auto runningTime = std::chrono::duration_cast<std::chrono::minutes>(steady_clock::now() - this->m_farm.farmLaunched());
1818

1919
SolutionStats s = this->m_farm.getSolutionStats();
2020
WorkingProgress p = this->m_farm.miningProgress();

‎libapicore/ApiServer.h

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class ApiServer : public AbstractServer<ApiServer>
1515
public:
1616
ApiServer(AbstractServerConnector *conn, serverVersion_t type, Farm &farm, bool &readonly);
1717
private:
18-
steady_clock::time_point m_started = steady_clock::now();
1918
Farm &m_farm;
2019
void getMinerStat1(const Json::Value& request, Json::Value& response);
2120
void doMinerRestart(const Json::Value& request, Json::Value& response);

‎libethcore/Farm.h

+19-1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,24 @@ class Farm: public FarmFace
217217

218218
WorkPackage work() const { Guard l(x_minerWork); return m_work; }
219219

220+
std::chrono::steady_clock::time_point farmLaunched() {
221+
return m_farm_launched;
222+
}
223+
224+
string farmLaunchedFormatted() {
225+
auto d = std::chrono::steady_clock::now() - m_farm_launched;
226+
int hsize = 3;
227+
auto hhh = std::chrono::duration_cast<std::chrono::hours>(d);
228+
if (hhh.count() < 100) {
229+
hsize = 2;
230+
}
231+
d -= hhh;
232+
auto mm = std::chrono::duration_cast<std::chrono::minutes>(d);
233+
std::ostringstream stream;
234+
stream << "Time: " << std::setfill('0') << std::setw(hsize) << hhh.count() << ':' << std::setfill('0') << std::setw(2) << mm.count();
235+
return stream.str();
236+
}
237+
220238
private:
221239
/**
222240
* @brief Called from a Miner to note a WorkPackage has a solution.
@@ -253,7 +271,7 @@ class Farm: public FarmFace
253271
bool b_lastMixed = false;
254272

255273
mutable SolutionStats m_solutionStats;
256-
274+
std::chrono::steady_clock::time_point m_farm_launched = std::chrono::steady_clock::now();
257275
};
258276

259277
}

0 commit comments

Comments
 (0)
This repository has been archived.