From 15fe6f0233f54b24e2b047990654b2d8bb982472 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Mon, 18 Apr 2016 05:57:38 +0000 Subject: [PATCH] dev of tx page started --- main.cpp | 11 ++++-- src/page.h | 26 ++++++++++++-- src/templates/tx.html | 80 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 src/templates/tx.html diff --git a/main.cpp b/main.cpp index 50fa37d..d2e3ec3 100644 --- a/main.cpp +++ b/main.cpp @@ -85,9 +85,14 @@ int main(int ac, const char* av[]) { }); CROW_ROUTE(app, "/block/") - ([&](string block_hash) { - return xmrblocks.show_block(block_hash); - }); + ([&](string block_hash) { + return xmrblocks.show_block(block_hash); + }); + + CROW_ROUTE(app, "/tx/") + ([&](string tx_hash) { + return xmrblocks.show_tx(tx_hash); + }); CROW_ROUTE(app, "/autorefresh") ([&]() { diff --git a/src/page.h b/src/page.h index 9da5710..2d0807f 100644 --- a/src/page.h +++ b/src/page.h @@ -20,7 +20,7 @@ #include #include -#include +#include #define TMPL_DIR "./templates" #define TMPL_INDEX TMPL_DIR "/index.html" @@ -28,7 +28,7 @@ #define TMPL_HEADER TMPL_DIR "/header.html" #define TMPL_FOOTER TMPL_DIR "/footer.html" #define TMPL_BLOCK TMPL_DIR "/block.html" - +#define TMPL_TX TMPL_DIR "/tx.html" namespace xmreg { @@ -527,6 +527,28 @@ namespace xmreg { return show_block(blk_height); } + string + show_tx(string _tx_hash) + { + + uint64_t _blk_height {0}; + + // initalise page tempate map with basic info about blockchain + mstch::map context { + {"tx_hash" , _tx_hash}, + {"blk_height" , _blk_height} + }; + + // read tx.html + string tx_html = xmreg::read(TMPL_TX); + + // add header and footer + string full_page = get_full_page(tx_html); + + // render the page + return mstch::render(full_page, context); + } + private: diff --git a/src/templates/tx.html b/src/templates/tx.html new file mode 100644 index 0000000..d87e320 --- /dev/null +++ b/src/templates/tx.html @@ -0,0 +1,80 @@ + +
+ +

Tx hash (block height): {{blk_hash}} ({{blk_height}})

+ + + {{#have_prev_hash}} +
Previous block: {{prev_hash}}
+ {{/have_prev_hash}} + + {{#have_next_hash}} +
Next block: {{next_hash}}
+ {{/have_next_hash}} + + + + + + + + + + + + + + + + + + + +
Timestamp [UCT]:{{blk_timestamp}}Age {{age_format}}:{{blk_age}}Δ [h:m:s]:{{delta_time}}
Major.minor version:{{major_ver}}.{{minor_ver}}Block reward:{{blk_reward}}Block size [kB]:{{blk_size}}
nonce:{{blk_nonce}}Total fees:{{sum_fees}}No of txs:{{no_txs}}
+ +

Miner reward transaction

+ + + + + + + + {{#coinbase_txs}} + + + + + + + {{/coinbase_txs}} + +
hashoutputssize [kB]version
{{hash}}{{sum_outputs}}{{tx_size}}{{version}}
+ + + +

Transactions ({{no_txs}})

+ {{#have_txs}} + + + + + + + + + + {{#blk_txs}} + + + + + + + + + {{/blk_txs}} +
hashoutputsfeemixin nosize [kB]version
{{hash}}{{sum_outputs}}{{tx_fee}}{{mixin}}{{tx_size}}{{version}}
+ {{/have_txs}} + +