From 6bdf82b59da6e7dcdeae3af8e5ab3ae89382f8a7 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 20 Jan 2017 01:36:35 +0000 Subject: [PATCH 1/5] CmakeLists.txt modified --- CMakeLists.txt | 7 +------ main.cpp | 5 +++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 466e009..571de21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,5 @@ cmake_minimum_required(VERSION 2.8) -#list(INSERT - # CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake) -set(CMAKE_MODULE_PATH - ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - set(PROJECT_NAME xmrblocks) @@ -191,7 +186,7 @@ set(LIBRARIES crypto ssl) -if (!APPLE) +if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(LIBRARIES ${LIBRARIES} unwind) endif() diff --git a/main.cpp b/main.cpp index b69efe6..f626e1a 100644 --- a/main.cpp +++ b/main.cpp @@ -304,6 +304,11 @@ int main(int ac, const char* av[]) { return xmrblocks.search(string(req.url_params.get("value"))); }); + CROW_ROUTE(app, "/mempool") + ([&](const crow::request& req) { + return xmrblocks.mempool(); + }); + CROW_ROUTE(app, "/robots.txt") ([&]() { string text = "User-agent: *\n" From c9204be4debd215a91e6a80632d5c66c563b003c Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 20 Jan 2017 01:43:09 +0000 Subject: [PATCH 2/5] /mempool page added --- main.cpp | 2 +- src/page.h | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index f626e1a..4b7a21f 100644 --- a/main.cpp +++ b/main.cpp @@ -306,7 +306,7 @@ int main(int ac, const char* av[]) { CROW_ROUTE(app, "/mempool") ([&](const crow::request& req) { - return xmrblocks.mempool(); + return xmrblocks.mempool(true); }); CROW_ROUTE(app, "/robots.txt") diff --git a/src/page.h b/src/page.h index 8f1050d..af1caa2 100644 --- a/src/page.h +++ b/src/page.h @@ -651,7 +651,7 @@ public: * Render mempool data */ string - mempool() + mempool(bool add_header_and_footer = false) { std::vector mempool_txs; @@ -774,9 +774,22 @@ public: return t1 > t2; }); - // read index.html + + // read mempool.html string mempool_html = xmreg::read(TMPL_MEMPOOL); + if (add_header_and_footer) + { + add_css_style(context); + + // add header and footer + string full_page = get_full_page(mempool_html); + + // render the page + return mstch::render(full_page, context); + } + + // render the page return mstch::render(mempool_html, context); } From c056d0ec3ae0a25b9ecf60d45f3e10badeafe993 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 20 Jan 2017 02:25:42 +0000 Subject: [PATCH 3/5] limit number of tx on front page to 25 --- src/page.h | 21 ++++++++++++++++++++- src/templates/mempool.html | 16 ++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/page.h b/src/page.h index af1caa2..ba5a8a7 100644 --- a/src/page.h +++ b/src/page.h @@ -258,6 +258,9 @@ class page { bool enable_pusher; + uint64_t no_of_mempool_tx_of_frontpage; + + public: page(MicroCore* _mcore, Blockchain* _core_storage, @@ -272,6 +275,7 @@ public: enable_pusher {_enable_pusher} { css_styles = xmreg::read(TMPL_CSS_STYLES); + no_of_mempool_tx_of_frontpage = 25; } @@ -774,14 +778,16 @@ public: return t1 > t2; }); - // read mempool.html string mempool_html = xmreg::read(TMPL_MEMPOOL); if (add_header_and_footer) { + // this is when mempool is on its own page, /mempool add_css_style(context); + context["partial_mempool_shown"] = false; + // add header and footer string full_page = get_full_page(mempool_html); @@ -789,6 +795,19 @@ public: return mstch::render(full_page, context); } + // this is for partial disply on front page. + + context["mempool_fits_on_front_page"] = (txs.size() <= no_of_mempool_tx_of_frontpage); + context["no_of_mempool_tx_of_frontpage"] = no_of_mempool_tx_of_frontpage; + + if (txs.size() > no_of_mempool_tx_of_frontpage) + { + // dont show more than the specific number mempool txs on + // the front page + txs.resize(no_of_mempool_tx_of_frontpage); + } + + context["partial_mempool_shown"] = true; // render the page return mstch::render(mempool_html, context); diff --git a/src/templates/mempool.html b/src/templates/mempool.html index 05f79a5..b1adb7f 100644 --- a/src/templates/mempool.html +++ b/src/templates/mempool.html @@ -1,12 +1,14 @@ -

- Memory pool (no of txs: {{mempool_size}}, size: {{mempool_size_kB}} kB) +

+ Memory pool

+

(no of txs: {{mempool_size}}, size: {{mempool_size_kB}} kB)

+ @@ -19,6 +21,7 @@ + @@ -30,5 +33,14 @@ {{/mempooltxs}}
height age [h:m:s]size [kB] transaction hash fee outputs
N/A {{age}}N/A {{hash}} {{fee}} {{xmr_outputs}}
+ {{^mempool_fits_on_front_page}} + {{#partial_mempool_shown}} +
+ Only {{no_of_mempool_tx_of_frontpage}} txs shown. Click this to see all + + {{/partial_mempool_shown}} + + {{/mempool_fits_on_front_page}} +
From 6d8a90b68f51ee526586a33a92124d36e797ae61 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 20 Jan 2017 02:48:12 +0000 Subject: [PATCH 4/5] html correced --- src/templates/mempool.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/mempool.html b/src/templates/mempool.html index b1adb7f..3a50b5d 100644 --- a/src/templates/mempool.html +++ b/src/templates/mempool.html @@ -37,7 +37,7 @@ {{#partial_mempool_shown}} {{/partial_mempool_shown}} {{/mempool_fits_on_front_page}} From c2b0bb343ef85cf559e6e07b7d8f5fed1868290b Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 20 Jan 2017 03:43:42 +0000 Subject: [PATCH 5/5] mempool html text amended --- src/templates/mempool.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/mempool.html b/src/templates/mempool.html index 3a50b5d..0cb810f 100644 --- a/src/templates/mempool.html +++ b/src/templates/mempool.html @@ -36,7 +36,7 @@ {{^mempool_fits_on_front_page}} {{#partial_mempool_shown}} {{/partial_mempool_shown}}