no_of_last_blocks option added and default set to 10

This commit is contained in:
moneroexamples 2017-03-04 06:25:24 +08:00
parent 89ec634422
commit 87ec3934f0
4 changed files with 34 additions and 23 deletions

View File

@ -45,14 +45,18 @@ int main(int ac, const char* av[]) {
auto deamon_url_opt = opts.get_option<string>("deamon-url");
auto ssl_crt_file_opt = opts.get_option<string>("ssl-crt-file");
auto ssl_key_file_opt = opts.get_option<string>("ssl-key-file");
auto no_blocks_on_index_opt = opts.get_option<string>("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<uint16_t>(*port_opt);
// cast no_blocks_on_index_opt to uint
uint64_t no_blocks_on_index = boost::lexical_cast<uint64_t>(*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;

View File

@ -35,6 +35,8 @@ namespace xmreg
"enable users to have the index page on autorefresh")
("port,p", value<string>()->default_value("8081"),
"default port")
("no-blocks-on-index", value<string>()->default_value("10"),
"number of last blocks to be shown on index page")
("bc-path,b", value<string>(),
"path to lmdb blockchain")
("ssl-crt-file", value<string>(),

View File

@ -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,7 +339,7 @@ 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();
@ -352,6 +355,7 @@ public:
{"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},

View File

@ -31,7 +31,7 @@
{{{mempool_info}}}
{{#is_page_zero}}
<h2 style="margin-bottom: 0px">Transactions in the last 25 blocks</h2>
<h2 style="margin-bottom: 0px">Transactions in the last {{no_of_last_blocks}} blocks</h2>
{{/is_page_zero}}
{{^is_page_zero}}
<h2 style="margin-bottom: 0px">Transactions in older blocks<!--(height: {{height}})--></h2>