From 5444701c389d595c7ab66222b1e41276a54983e4 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sun, 2 Jul 2023 15:33:51 +0200 Subject: [PATCH] Tweaked `status` code Don't create stream when it's not needed --- src/miner.cpp | 2 +- src/p2p_server.cpp | 2 +- src/stratum_server.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 00a8baa..e3de9b4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -85,11 +85,11 @@ void Miner::print_status() const uint64_t hr = (dt > 0.0) ? static_cast(hash_count / dt) : 0; char shares_failed_buf[64] = {}; - log::Stream s(shares_failed_buf); const uint32_t shares_found = m_sharesFound; const uint32_t shares_failed = m_sharesFailed; if (shares_failed) { + log::Stream s(shares_failed_buf); s << log::Yellow() << "\nShares failed = " << shares_failed << log::NoColor(); } diff --git a/src/p2p_server.cpp b/src/p2p_server.cpp index 8a41edc..0482c71 100644 --- a/src/p2p_server.cpp +++ b/src/p2p_server.cpp @@ -986,8 +986,8 @@ void P2PServer::show_peers() const for (P2PClient* client = static_cast(m_connectedClientsList->m_next); client != m_connectedClientsList; client = static_cast(client->m_next)) { if (client->m_listenPort >= 0) { char buf[32] = {}; - log::Stream s(buf); if (client->m_SoftwareVersion) { + log::Stream s(buf); s << client->software_name() << " v" << (client->m_SoftwareVersion >> 16) << '.' << (client->m_SoftwareVersion & 0xFFFF); } LOGINFO(0, (client->m_isIncoming ? "I\t" : "O\t") diff --git a/src/stratum_server.cpp b/src/stratum_server.cpp index 2caa7f9..db655b5 100644 --- a/src/stratum_server.cpp +++ b/src/stratum_server.cpp @@ -589,8 +589,8 @@ void StratumServer::print_stratum_status() const const uint64_t hashrate_24h = (dt_24h > 0) ? (hashes_24h / dt_24h) : 0; char shares_failed_buf[64] = {}; - log::Stream s(shares_failed_buf); if (shares_failed) { + log::Stream s(shares_failed_buf); s << log::Yellow() << "\nShares failed = " << shares_failed << log::NoColor(); }