diff --git a/main.cpp b/main.cpp index 945b532..e5d0b8c 100644 --- a/main.cpp +++ b/main.cpp @@ -39,20 +39,24 @@ int main(int ac, const char* av[]) { bool enable_autorefresh_option {*enable_autorefresh_option_opt}; bool enable_output_key_checker {*enable_output_key_checker_opt}; - auto port_opt = opts.get_option("port"); - auto bc_path_opt = opts.get_option("bc-path"); - auto custom_db_path_opt = opts.get_option("custom-db-path"); - auto deamon_url_opt = opts.get_option("deamon-url"); - auto ssl_crt_file_opt = opts.get_option("ssl-crt-file"); - auto ssl_key_file_opt = opts.get_option("ssl-key-file"); + auto port_opt = opts.get_option("port"); + auto bc_path_opt = opts.get_option("bc-path"); + auto custom_db_path_opt = opts.get_option("custom-db-path"); + auto deamon_url_opt = opts.get_option("deamon-url"); + auto ssl_crt_file_opt = opts.get_option("ssl-crt-file"); + auto ssl_key_file_opt = opts.get_option("ssl-key-file"); + auto no_blocks_on_index_opt = opts.get_option("no-blocks-on-index"); // set monero log output level uint32_t log_level = 0; mlog_configure("", true); - //cast port number in string to uint16 + //cast port number in string to uint uint16_t app_port = boost::lexical_cast(*port_opt); + // cast no_blocks_on_index_opt to uint + uint64_t no_blocks_on_index = boost::lexical_cast(*no_blocks_on_index_opt); + bool use_ssl {false}; string ssl_crt_file; @@ -155,7 +159,8 @@ int main(int ac, const char* av[]) { enable_pusher, enable_key_image_checker, enable_output_key_checker, - enable_autorefresh_option); + enable_autorefresh_option, + no_blocks_on_index); // crow instance crow::SimpleApp app; diff --git a/src/CmdLineOptions.cpp b/src/CmdLineOptions.cpp index c67601c..aa2fe07 100644 --- a/src/CmdLineOptions.cpp +++ b/src/CmdLineOptions.cpp @@ -35,6 +35,8 @@ namespace xmreg "enable users to have the index page on autorefresh") ("port,p", value()->default_value("8081"), "default port") + ("no-blocks-on-index", value()->default_value("10"), + "number of last blocks to be shown on index page") ("bc-path,b", value(), "path to lmdb blockchain") ("ssl-crt-file", value(), diff --git a/src/page.h b/src/page.h index 057d70d..ed00ef5 100644 --- a/src/page.h +++ b/src/page.h @@ -268,6 +268,7 @@ class page { uint64_t no_of_mempool_tx_of_frontpage; + uint64_t no_blocks_on_index; public: @@ -277,7 +278,8 @@ public: bool _testnet, bool _enable_pusher, bool _enable_key_image_checker, bool _enable_output_key_checker, - bool _enable_autorefresh_option) + bool _enable_autorefresh_option, + uint64_t _no_blocks_on_index) : mcore {_mcore}, core_storage {_core_storage}, rpc {_deamon_url}, @@ -288,7 +290,8 @@ public: have_custom_lmdb {false}, enable_key_image_checker {_enable_key_image_checker}, enable_output_key_checker {_enable_output_key_checker}, - enable_autorefresh_option {_enable_autorefresh_option} + enable_autorefresh_option {_enable_autorefresh_option}, + no_blocks_on_index {_no_blocks_on_index} { css_styles = xmreg::read(TMPL_CSS_STYLES); no_of_mempool_tx_of_frontpage = 25; @@ -336,24 +339,25 @@ public: server_timestamp = std::time(nullptr); // number of last blocks to show - uint64_t no_of_last_blocks {25 + 1}; + uint64_t no_of_last_blocks {no_blocks_on_index + 1}; // get the current blockchain height. Just to check uint64_t height = core_storage->get_current_blockchain_height(); // initalise page tempate map with basic info about blockchain mstch::map context { - {"testnet" , testnet}, - {"have_custom_lmdb", have_custom_lmdb}, - {"refresh" , refresh_page}, - {"height" , std::to_string(height)}, - {"server_timestamp", xmreg::timestamp_to_str(server_timestamp)}, - {"age_format" , string("[h:m:d]")}, - {"page_no" , std::to_string(page_no)}, - {"total_page_no" , std::to_string(height / (no_of_last_blocks))}, - {"is_page_zero" , !bool(page_no)}, - {"next_page" , std::to_string(page_no + 1)}, - {"prev_page" , std::to_string((page_no > 0 ? page_no - 1 : 0))}, + {"testnet" , testnet}, + {"have_custom_lmdb" , have_custom_lmdb}, + {"refresh" , refresh_page}, + {"height" , std::to_string(height)}, + {"server_timestamp" , xmreg::timestamp_to_str(server_timestamp)}, + {"age_format" , string("[h:m:d]")}, + {"page_no" , std::to_string(page_no)}, + {"total_page_no" , std::to_string(height / (no_of_last_blocks))}, + {"is_page_zero" , !bool(page_no)}, + {"no_of_last_blocks", no_of_last_blocks}, + {"next_page" , std::to_string(page_no + 1)}, + {"prev_page" , std::to_string((page_no > 0 ? page_no - 1 : 0))}, {"enable_pusher" , enable_pusher}, {"enable_key_image_checker" , enable_key_image_checker}, {"enable_output_key_checker", enable_output_key_checker}, diff --git a/src/templates/index2.html b/src/templates/index2.html index b01e61a..62b251f 100644 --- a/src/templates/index2.html +++ b/src/templates/index2.html @@ -31,7 +31,7 @@ {{{mempool_info}}} {{#is_page_zero}} -

Transactions in the last 25 blocks

+

Transactions in the last {{no_of_last_blocks}} blocks

{{/is_page_zero}} {{^is_page_zero}}

Transactions in older blocks