diff --git a/src/page.h b/src/page.h index a1fff20..cbe152c 100644 --- a/src/page.h +++ b/src/page.h @@ -72,6 +72,8 @@ namespace xmreg { // get reference to blocks template map to be field below mstch::array& blocks = boost::get(context["blocks"]); + time_t prev_blk_timestamp {0}; + // iterate over last no_of_last_blocks of blocks 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); + // get block's hash 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 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 array coinbase_tx = sum_money_in_tx(blk.miner_tx); @@ -117,10 +137,11 @@ namespace xmreg { return fmt::format("{:d} - {:d}", mixin_min, mixin_max); }; + // set output page template map blocks.push_back(mstch::map { {"height" , to_string(i)}, - {"timestamp" , xmreg::timestamp_to_str(blk.timestamp)}, + {"timestamp" , timestamp_str}, {"hash" , fmt::format("{:s}", blk_hash)}, {"block_reward", fmt::format("{:0.4f}", XMR_AMOUNT(coinbase_tx[1]))}, {"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]))}, {"mixin_range" , mstch::lambda {mixin_format}} }); + + prev_blk_timestamp = blk.timestamp; } // read index.html diff --git a/src/templates/css/style.css b/src/templates/css/style.css index 42735b0..5197f82 100644 --- a/src/templates/css/style.css +++ b/src/templates/css/style.css @@ -2,4 +2,8 @@ tr { font-family: "Lucida Console", Monaco, monospace; font-size : 12px; height: 22px; +} + +td { + text-align: center; } \ No newline at end of file diff --git a/src/templates/header.html b/src/templates/header.html index a9a6300..ae4f01f 100644 --- a/src/templates/header.html +++ b/src/templates/header.html @@ -2,6 +2,7 @@ + Hidden Monero Explorer diff --git a/src/templates/index.html b/src/templates/index.html index 125af8a..4b60d5a 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -6,7 +6,7 @@ - +
heighttimestamptimestamp (Δ mm:ss) block_hash block_reward no_of_txs