From 7bb80afea81fe0a9a821d12b05f146994b7f817b Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Sat, 7 Jul 2018 08:41:40 +0800 Subject: [PATCH] improve formating of hash rate --- src/page.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/page.h b/src/page.h index b46dfa3..b60efdc 100644 --- a/src/page.h +++ b/src/page.h @@ -881,14 +881,12 @@ public: // perapre network info mstch::map for the front page string hash_rate; - if (testnet || stagenet) - { - hash_rate = std::to_string(current_network_info.hash_rate) + " H/s"; - } - else - { + if (current_network_info.hash_rate > 1e6) hash_rate = fmt::format("{:0.3f} MH/s", current_network_info.hash_rate/1.0e6); - } + else if (current_network_info.hash_rate > 1e3) + hash_rate = fmt::format("{:0.3f} kH/s", current_network_info.hash_rate/1.0e3); + else + hash_rate = fmt::format("{:0.3f} H/s", current_network_info.hash_rate); pair network_info_age = get_age(local_copy_server_timestamp, current_network_info.info_timestamp);