moneroexamples 7 years ago
parent 7765bf06c4
commit 4c432be311

@ -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<double>(
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<double>(
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<uint64_t>(std::time(nullptr));

@ -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};

@ -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<double>(
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}

@ -71,7 +71,7 @@
<h2 style="margin-bottom: 0px">Transactions in older blocks<!--(height: {{height}})--></h2>
{{/is_page_zero}}
<h4 style="font-size: 14px; margin-top: 0px">(Median size of these blocks: {{blk_size_median}} kB)</h4>
<h4 style="font-size: 14px; margin-top: 0px">(Median size of 100 blocks: {{blk_size_median}} kB)</h4>
<div class="center">

Loading…
Cancel
Save