dev of tx page started

master
moneroexamples 9 years ago
parent ed7b5806d2
commit 15fe6f0233

@ -85,9 +85,14 @@ int main(int ac, const char* av[]) {
});
CROW_ROUTE(app, "/block/<string>")
([&](string block_hash) {
return xmrblocks.show_block(block_hash);
});
([&](string block_hash) {
return xmrblocks.show_block(block_hash);
});
CROW_ROUTE(app, "/tx/<string>")
([&](string tx_hash) {
return xmrblocks.show_tx(tx_hash);
});
CROW_ROUTE(app, "/autorefresh")
([&]() {

@ -20,7 +20,7 @@
#include <algorithm>
#include <limits>
#include<ctime>
#include <ctime>
#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:

@ -0,0 +1,80 @@
<div>
<H4>Tx hash (block height): {{blk_hash}} ({{blk_height}})</H4>
{{#have_prev_hash}}
<H5>Previous block: <a href="/block/{{prev_hash}}">{{prev_hash}}</a></H5>
{{/have_prev_hash}}
{{#have_next_hash}}
<H5>Next block: <a href="/block/{{next_hash}}">{{next_hash}}</a></H5>
{{/have_next_hash}}
<table class="center">
<tr>
<td>Timestamp [UCT]:</td><td>{{blk_timestamp}}</td>
<td>Age {{age_format}}:</td><td>{{blk_age}}</td>
<td>Δ [h:m:s]:</td><td>{{delta_time}}</td>
</tr>
<tr>
<td>Major.minor version:</td><td>{{major_ver}}.{{minor_ver}}</td>
<td>Block reward:</td><td>{{blk_reward}}</td>
<td>Block size [kB]:</td><td>{{blk_size}}</td>
</tr>
<tr>
<td>nonce:</td><td>{{blk_nonce}}</td>
<td>Total fees:</td><td>{{sum_fees}}</td>
<td>No of txs:</td><td>{{no_txs}}</td>
</tr>
</table>
<h3>Miner reward transaction</h3>
<table class="center">
<tr>
<td>hash</td>
<td>outputs</td>
<td>size [kB]</td>
<td>version</td>
</tr>
{{#coinbase_txs}}
<tr>
<td>{{hash}}</td>
<td>{{sum_outputs}}</td>
<td>{{tx_size}}</td>
<td>{{version}}</td>
</tr>
{{/coinbase_txs}}
</table>
<h3>Transactions ({{no_txs}})</h3>
{{#have_txs}}
<table class="center" style="width:80%">
<tr>
<td>hash</td>
<td>outputs</td>
<td>fee</td>
<td>mixin no</td>
<td>size [kB]</td>
<td>version</td>
</tr>
{{#blk_txs}}
<tr>
<td>{{hash}}</td>
<td>{{sum_outputs}}</td>
<td>{{tx_fee}}</td>
<td>{{mixin}}</td>
<td>{{tx_size}}</td>
<td>{{version}}</td>
</tr>
{{/blk_txs}}
</table>
{{/have_txs}}
</div>
Loading…
Cancel
Save