time_delta reversed

master
moneroexamples 9 years ago
parent ec1a31cad6
commit 516a66b376

@ -67,7 +67,7 @@ namespace xmreg {
}; };
// number of last blocks to show // number of last blocks to show
size_t no_of_last_blocks {150}; size_t no_of_last_blocks {100 + 1};
// get reference to blocks template map to be field below // get reference to blocks template map to be field below
mstch::array& blocks = boost::get<mstch::array>(context["blocks"]); mstch::array& blocks = boost::get<mstch::array>(context["blocks"]);
@ -75,14 +75,14 @@ namespace xmreg {
time_t prev_blk_timestamp {0}; time_t prev_blk_timestamp {0};
// iterate over last no_of_last_blocks of blocks // iterate over last no_of_last_blocks of blocks
for (size_t i = height; i > height - no_of_last_blocks; --i) //for (size_t i = height; i > height - no_of_last_blocks; --i)
for (size_t i = height - no_of_last_blocks; i <= height; ++i)
{ {
// get block at the given height i // get block at the given height i
block blk; block blk;
mcore->get_block_by_height(i, blk); mcore->get_block_by_height(i, blk);
// get block's hash // get block's hash
crypto::hash blk_hash = core_storage->get_block_id_by_height(i); crypto::hash blk_hash = core_storage->get_block_id_by_height(i);
@ -96,11 +96,10 @@ namespace xmreg {
delta_minutes = delta_time[3]; delta_minutes = delta_time[3];
delta_seconds = delta_time[4]; delta_seconds = delta_time[4];
} }
string timestamp_str = xmreg::timestamp_to_str(blk.timestamp) string timestamp_str = xmreg::timestamp_to_str(blk.timestamp)
+ fmt::format(" (-{:02d}:{:02d})", + fmt::format(" ({:02d}:{:02d})",
delta_minutes, delta_seconds); delta_minutes, delta_seconds);
// get xmr in the block reward // get xmr in the block reward
@ -140,7 +139,6 @@ namespace xmreg {
return fmt::format("{:d} - {:d}", mixin_min, mixin_max); return fmt::format("{:d} - {:d}", mixin_min, mixin_max);
}; };
// set output page template map // set output page template map
blocks.push_back(mstch::map { blocks.push_back(mstch::map {
{"height" , to_string(i)}, {"height" , to_string(i)},
@ -150,14 +148,22 @@ namespace xmreg {
XMR_AMOUNT(coinbase_tx[1]), XMR_AMOUNT(coinbase_tx[1]),
XMR_AMOUNT(sum_fees))}, XMR_AMOUNT(sum_fees))},
{"notx" , fmt::format("{:d}", blk.tx_hashes.size())}, {"notx" , fmt::format("{:d}", blk.tx_hashes.size())},
{"xmr_inputs" , fmt::format("{:0.4f}", XMR_AMOUNT(sum_xmr_in_out[0]))}, {"xmr_inputs" , fmt::format("{:0.4f}",
{"xmr_outputs" , fmt::format("{:0.4f}", XMR_AMOUNT(sum_xmr_in_out[1]))}, XMR_AMOUNT(sum_xmr_in_out[0]))},
{"xmr_outputs" , fmt::format("{:0.4f}",
XMR_AMOUNT(sum_xmr_in_out[1]))},
{"mixin_range" , mstch::lambda {mixin_format}} {"mixin_range" , mstch::lambda {mixin_format}}
}); });
prev_blk_timestamp = blk.timestamp; prev_blk_timestamp = blk.timestamp;
} }
// reverse blocks and remove last (i.e., oldest)
// block. This is done so that time delats
// are easier to calcualte in the above for loop
std::reverse(blocks.begin(), blocks.end());
blocks.pop_back();
// read index.html // read index.html
std::string index_html = xmreg::read(TMPL_INDEX); std::string index_html = xmreg::read(TMPL_INDEX);

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta http-equiv="refresh" content="60" > <!--<meta http-equiv="refresh" content="60">-->
<title>Hidden Monero Explorer</title> <title>Hidden Monero Explorer</title>
<link rel="stylesheet" type="text/css" href="/css/style.css"> <link rel="stylesheet" type="text/css" href="/css/style.css">
</head> </head>

Loading…
Cancel
Save