diff --git a/src/MempoolStatus.cpp b/src/MempoolStatus.cpp index 883a96f..22c9d69 100644 --- a/src/MempoolStatus.cpp +++ b/src/MempoolStatus.cpp @@ -263,10 +263,24 @@ MempoolStatus::read_network_info() rpc_network_info.stagenet ? cryptonote::network_type::STAGENET : cryptonote::network_type::MAINNET; local_copy.cumulative_difficulty = rpc_network_info.cumulative_difficulty; local_copy.block_size_limit = rpc_network_info.block_size_limit; + local_copy.block_size_median = rpc_network_info.block_size_median; local_copy.start_time = rpc_network_info.start_time; - epee::string_tools::hex_to_pod(rpc_network_info.top_block_hash, local_copy.top_block_hash); + strncpy(local_copy.block_size_limit_str, fmt::format("{:0.2f}", + static_cast( + local_copy.block_size_limit ) / 2.0 / 1024.0).c_str(), + sizeof(local_copy.block_size_limit_str)); + + + strncpy(local_copy.block_size_median_str, fmt::format("{:0.2f}", + static_cast( + local_copy.block_size_median) / 1024.0).c_str(), + sizeof(local_copy.block_size_median_str)); + + epee::string_tools::hex_to_pod(rpc_network_info.top_block_hash, + local_copy.top_block_hash); + local_copy.fee_per_kb = fee_estimated; local_copy.info_timestamp = static_cast(std::time(nullptr)); diff --git a/src/MempoolStatus.h b/src/MempoolStatus.h index c2dd7e7..8f20762 100644 --- a/src/MempoolStatus.h +++ b/src/MempoolStatus.h @@ -71,6 +71,9 @@ struct MempoolStatus crypto::hash top_block_hash; uint64_t cumulative_difficulty {0}; uint64_t block_size_limit {0}; + uint64_t block_size_median {0}; + char block_size_limit_str[10] {"0.0"}; // needs to be trivially copyable + char block_size_median_str[10] {"0.0"} ; // std::string is not trivially copyable uint64_t start_time {0}; uint64_t current_hf_version {0}; diff --git a/src/page.h b/src/page.h index 281fc61..be1a2ba 100644 --- a/src/page.h +++ b/src/page.h @@ -790,9 +790,7 @@ public: } // while (i <= end_height) // calculate median size of the blocks shown - double blk_size_median = xmreg::calc_median(blk_sizes.begin(), blk_sizes.end()); - - context["blk_size_median"] = fmt::format("{:0.2f}", blk_size_median); + //double blk_size_median = xmreg::calc_median(blk_sizes.begin(), blk_sizes.end()); // save computational times for disply in the frontend @@ -835,10 +833,6 @@ public: current_network_info.current = true; } - string block_size_limit = fmt::format("{:0.2f}", - static_cast( - current_network_info.block_size_limit) / 2.0 / 1024.0); - context["network_info"] = mstch::map { {"difficulty" , current_network_info.difficulty}, {"hash_rate" , hash_rate}, @@ -846,7 +840,8 @@ public: {"alt_blocks_no" , current_network_info.alt_blocks_count}, {"have_alt_block" , (current_network_info.alt_blocks_count > 0)}, {"tx_pool_size" , current_network_info.tx_pool_size}, - {"block_size_limit" , block_size_limit}, + {"block_size_limit" , string {current_network_info.block_size_limit_str}}, + {"block_size_median" , string {current_network_info.block_size_median_str}}, {"is_current_info" , current_network_info.current}, {"is_pool_size_zero" , (current_network_info.tx_pool_size == 0)}, {"current_hf_version", current_network_info.current_hf_version}, @@ -854,6 +849,9 @@ public: {"age_format" , network_info_age.second}, }; + // median size of 100 blocks + context["blk_size_median"] = string {current_network_info.block_size_median_str}; + string mempool_html {"Cant get mempool_pool"}; // get mempool data for the front page, if ready. If not, then just skip. @@ -6253,6 +6251,7 @@ private: {"top_block_hash" , pod_to_hex(local_copy_network_info.top_block_hash)}, {"cumulative_difficulty" , local_copy_network_info.cumulative_difficulty}, {"block_size_limit" , local_copy_network_info.block_size_limit}, + {"block_size_median" , local_copy_network_info.block_size_median}, {"start_time" , local_copy_network_info.start_time}, {"fee_per_kb" , local_copy_network_info.fee_per_kb}, {"current_hf_version" , local_copy_network_info.current_hf_version} diff --git a/src/templates/index2.html b/src/templates/index2.html index 28c3102..0b74d10 100644 --- a/src/templates/index2.html +++ b/src/templates/index2.html @@ -71,7 +71,7 @@

Transactions in older blocks

{{/is_page_zero}} -

(Median size of these blocks: {{blk_size_median}} kB)

+

(Median size of 100 blocks: {{blk_size_median}} kB)