time difference between blocks added
This commit is contained in:
parent
8aa5698584
commit
6d7af118fa
25
src/page.h
25
src/page.h
|
@ -72,6 +72,8 @@ namespace xmreg {
|
||||||
// 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"]);
|
||||||
|
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
|
@ -80,9 +82,27 @@ namespace xmreg {
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
uint64_t delta_minutes {0};
|
||||||
|
uint64_t delta_seconds {0};
|
||||||
|
|
||||||
|
if (prev_blk_timestamp > 0)
|
||||||
|
{
|
||||||
|
array<size_t, 5> delta_time = timestamp_difference(
|
||||||
|
prev_blk_timestamp, blk.timestamp);
|
||||||
|
|
||||||
|
delta_minutes = delta_time[3];
|
||||||
|
delta_seconds = delta_time[4];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
string timestamp_str = xmreg::timestamp_to_str(blk.timestamp)
|
||||||
|
+ fmt::format(" (-{:02d}:{:02d})",
|
||||||
|
delta_minutes, delta_seconds);
|
||||||
|
|
||||||
// get xmr in the block reward
|
// get xmr in the block reward
|
||||||
array<uint64_t, 2> coinbase_tx = sum_money_in_tx(blk.miner_tx);
|
array<uint64_t, 2> coinbase_tx = sum_money_in_tx(blk.miner_tx);
|
||||||
|
|
||||||
|
@ -117,10 +137,11 @@ 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)},
|
||||||
{"timestamp" , xmreg::timestamp_to_str(blk.timestamp)},
|
{"timestamp" , timestamp_str},
|
||||||
{"hash" , fmt::format("{:s}", blk_hash)},
|
{"hash" , fmt::format("{:s}", blk_hash)},
|
||||||
{"block_reward", fmt::format("{:0.4f}", XMR_AMOUNT(coinbase_tx[1]))},
|
{"block_reward", fmt::format("{:0.4f}", XMR_AMOUNT(coinbase_tx[1]))},
|
||||||
{"notx" , fmt::format("{:d}", blk.tx_hashes.size())},
|
{"notx" , fmt::format("{:d}", blk.tx_hashes.size())},
|
||||||
|
@ -128,6 +149,8 @@ namespace xmreg {
|
||||||
{"xmr_outputs" , fmt::format("{:0.4f}", XMR_AMOUNT(sum_xmr_in_out[1]))},
|
{"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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read index.html
|
// read index.html
|
||||||
|
|
|
@ -2,4 +2,8 @@ tr {
|
||||||
font-family: "Lucida Console", Monaco, monospace;
|
font-family: "Lucida Console", Monaco, monospace;
|
||||||
font-size : 12px;
|
font-size : 12px;
|
||||||
height: 22px;
|
height: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
<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>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>height</td>
|
<td>height</td>
|
||||||
<td>timestamp</td>
|
<td>timestamp (Δ mm:ss)</td>
|
||||||
<td>block_hash</td>
|
<td>block_hash</td>
|
||||||
<td>block_reward</td>
|
<td>block_reward</td>
|
||||||
<td>no_of_txs</td>
|
<td>no_of_txs</td>
|
||||||
|
|
Loading…
Reference in New Issue