From 5d34b3e562bf4a287a8e4144dbc9cc4d506071ed Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 22 Dec 2017 08:29:22 +0800 Subject: [PATCH] hard fork version added to network info --- src/MempoolStatus.cpp | 3 +++ src/MempoolStatus.h | 1 + src/page.h | 4 +++- src/templates/index2.html | 1 + src/tools.h | 5 +++-- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/MempoolStatus.cpp b/src/MempoolStatus.cpp index 380d087..4d186e0 100644 --- a/src/MempoolStatus.cpp +++ b/src/MempoolStatus.cpp @@ -249,10 +249,13 @@ MempoolStatus::read_network_info() local_copy.block_size_limit = rpc_network_info.block_size_limit; 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); local_copy.fee_per_kb = fee_estimated; local_copy.info_timestamp = static_cast(std::time(nullptr)); + local_copy.current_hf_version = core_storage->get_current_hard_fork_version(); + local_copy.current = true; current_network_info = local_copy; diff --git a/src/MempoolStatus.h b/src/MempoolStatus.h index 8a42ab5..32418e1 100644 --- a/src/MempoolStatus.h +++ b/src/MempoolStatus.h @@ -71,6 +71,7 @@ struct MempoolStatus uint64_t cumulative_difficulty {0}; uint64_t block_size_limit {0}; uint64_t start_time {0}; + uint64_t current_hf_version {0}; uint64_t hash_rate {0}; uint64_t fee_per_kb {0}; diff --git a/src/page.h b/src/page.h index 43852d3..f65bca8 100644 --- a/src/page.h +++ b/src/page.h @@ -747,6 +747,7 @@ namespace xmreg {"block_size_limit" , block_size_limit}, {"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}, {"age" , network_info_age.first}, {"age_format" , network_info_age.second}, }; @@ -6069,7 +6070,8 @@ namespace xmreg {"cumulative_difficulty" , local_copy_network_info.cumulative_difficulty}, {"block_size_limit" , local_copy_network_info.block_size_limit}, {"start_time" , local_copy_network_info.start_time}, - {"fee_per_kb" , local_copy_network_info.fee_per_kb} + {"fee_per_kb" , local_copy_network_info.fee_per_kb}, + {"current_hf_version" , local_copy_network_info.current_hf_version} }; return local_copy_network_info.current; diff --git a/src/templates/index2.html b/src/templates/index2.html index c83eb91..32ab590 100644 --- a/src/templates/index2.html +++ b/src/templates/index2.html @@ -37,6 +37,7 @@ {{#network_info}}

Network difficulty: {{difficulty}} + | Hard fork: v{{current_hf_version}} | Hash rate: {{hash_rate}} | Fee per kb: {{fee_per_kb}} | Median block size limit: {{block_size_limit}} kB diff --git a/src/tools.h b/src/tools.h index ba4d153..32d2236 100644 --- a/src/tools.h +++ b/src/tools.h @@ -332,10 +332,11 @@ void chunks(Iterator begin, * Remove all characters in in_str that match the given * regular expression */ +template inline string -remove_bad_chars(string const& in_str, std::regex const& rgx = std::regex ("[^a-zA-Z0-9]")) +remove_bad_chars(T&& in_str, std::regex const& rgx = std::regex ("[^a-zA-Z0-9]")) { - return std::regex_replace(in_str, rgx, ""); + return std::regex_replace(std::forward(in_str), rgx, ""); }