diff --git a/src/p2p_server.cpp b/src/p2p_server.cpp index ba14d32..143b7dc 100644 --- a/src/p2p_server.cpp +++ b/src/p2p_server.cpp @@ -688,9 +688,25 @@ uint64_t P2PServer::get_random64() void P2PServer::print_status() { + const int64_t uptime = time(nullptr) - m_pool->start_time(); + + const int64_t s = uptime % 60; + const int64_t m = (uptime / 60) % 60; + const int64_t h = (uptime / 3600) % 24; + const int64_t d = uptime / 86400; + + char buf[log::Stream::BUF_SIZE + 1]; + log::Stream s1(buf); + + if (d > 0) { + s1 << d << "d "; + } + s1 << h << "h " << m << "m " << s << 's'; + LOGINFO(0, "status" << "\nConnections = " << m_numConnections << " (" << m_numIncomingConnections << " incoming)" << - "\nPeer list size = " << m_peerList.size() + "\nPeer list size = " << m_peerList.size() << + "\nUptime = " << log::const_buf(buf, s1.m_pos) ); } diff --git a/src/p2pool.cpp b/src/p2pool.cpp index b043f04..6efdc4e 100644 --- a/src/p2pool.cpp +++ b/src/p2pool.cpp @@ -49,6 +49,8 @@ p2pool::p2pool(int argc, char* argv[]) , m_params(new Params(argc, argv)) , m_updateSeed(true) , m_submitBlockData{} + , m_zmqLastActive(0) + , m_startTime(time(nullptr)) { LOGINFO(1, log::LightCyan() << VERSION); diff --git a/src/p2pool.h b/src/p2pool.h index a7b1cd7..c69b9f3 100644 --- a/src/p2pool.h +++ b/src/p2pool.h @@ -78,6 +78,7 @@ public: bool get_difficulty_at_height(uint64_t height, difficulty_type& diff); time_t zmq_last_active() const { return m_zmqLastActive; } + time_t start_time() const { return m_startTime; } private: p2pool(const p2pool&) = delete; @@ -169,7 +170,8 @@ private: uv_async_t m_blockTemplateAsync; uv_async_t m_stopAsync; - time_t m_zmqLastActive = 0; + time_t m_zmqLastActive; + time_t m_startTime; }; } // namespace p2pool