|
|
@ -62,11 +62,14 @@ namespace xmreg {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string
|
|
|
|
string
|
|
|
|
index(bool refresh_page = false)
|
|
|
|
index(uint64_t page_no = 0, bool refresh_page = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//get current server timestamp
|
|
|
|
//get current server timestamp
|
|
|
|
server_timestamp = std::time(nullptr);
|
|
|
|
server_timestamp = std::time(nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// number of last blocks to show
|
|
|
|
|
|
|
|
uint64_t no_of_last_blocks {100 + 1};
|
|
|
|
|
|
|
|
|
|
|
|
// get the current blockchain height. Just to check if it reads ok.
|
|
|
|
// get the current blockchain height. Just to check if it reads ok.
|
|
|
|
// uint64_t height = core_storage->get_current_blockchain_height() - 1;
|
|
|
|
// uint64_t height = core_storage->get_current_blockchain_height() - 1;
|
|
|
|
|
|
|
|
|
|
|
@ -77,17 +80,31 @@ namespace xmreg {
|
|
|
|
{"refresh" , refresh_page},
|
|
|
|
{"refresh" , refresh_page},
|
|
|
|
{"height" , fmt::format("{:d}", height)},
|
|
|
|
{"height" , fmt::format("{:d}", height)},
|
|
|
|
{"server_timestamp", xmreg::timestamp_to_str(server_timestamp)},
|
|
|
|
{"server_timestamp", xmreg::timestamp_to_str(server_timestamp)},
|
|
|
|
{"blocks", mstch::array()}
|
|
|
|
{"blocks" , mstch::array()},
|
|
|
|
|
|
|
|
{"page_no" , fmt::format("{:d}", page_no)},
|
|
|
|
|
|
|
|
{"total_page_no" , fmt::format("{:d}", height / (no_of_last_blocks))},
|
|
|
|
|
|
|
|
{"is_page_zero" , bool(page_no)},
|
|
|
|
|
|
|
|
{"next_page" , fmt::format("{:d}", page_no + 1)},
|
|
|
|
|
|
|
|
{"prev_page" , fmt::format("{:d}", (page_no > 0 ? page_no - 1 : 0))},
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// number of last blocks to show
|
|
|
|
|
|
|
|
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"]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t start_height = height - no_of_last_blocks * (page_no + 1);
|
|
|
|
|
|
|
|
uint64_t end_height = height - no_of_last_blocks * (page_no);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
start_height = start_height > 0 ? start_height : 0;
|
|
|
|
|
|
|
|
end_height = end_height < height ? end_height : height;
|
|
|
|
|
|
|
|
start_height = start_height > end_height ? 0 : start_height;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cout << start_height << ", " << end_height << endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// iterate over last no_of_last_blocks of blocks
|
|
|
|
// iterate over last no_of_last_blocks of blocks
|
|
|
|
for (size_t i = height - no_of_last_blocks; i <= height; ++i)
|
|
|
|
for (uint64_t i = start_height; i <= end_height; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// get block at the given height i
|
|
|
|
// get block at the given height i
|
|
|
|
block blk;
|
|
|
|
block blk;
|
|
|
@ -109,6 +126,21 @@ namespace xmreg {
|
|
|
|
delta_time[2], delta_time[3],
|
|
|
|
delta_time[2], delta_time[3],
|
|
|
|
delta_time[4]);
|
|
|
|
delta_time[4]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if have days or yeras, change age format
|
|
|
|
|
|
|
|
if (delta_time[0] > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
age_str = fmt::format("{:02d}:{:02d}:{:02d}:{:02d}:{:02d}",
|
|
|
|
|
|
|
|
delta_time[0], delta_time[1], delta_time[2],
|
|
|
|
|
|
|
|
delta_time[3], delta_time[4]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (delta_time[1] > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
age_str = fmt::format("{:02d}:{:02d}:{:02d}:{:02d}",
|
|
|
|
|
|
|
|
delta_time[1], delta_time[2],
|
|
|
|
|
|
|
|
delta_time[3], delta_time[4]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
|
|
|
@ -172,7 +204,7 @@ namespace xmreg {
|
|
|
|
// block. This is done so that time delats
|
|
|
|
// block. This is done so that time delats
|
|
|
|
// are easier to calcualte in the above for loop
|
|
|
|
// are easier to calcualte in the above for loop
|
|
|
|
std::reverse(blocks.begin(), blocks.end());
|
|
|
|
std::reverse(blocks.begin(), blocks.end());
|
|
|
|
blocks.pop_back();
|
|
|
|
//blocks.pop_back();
|
|
|
|
|
|
|
|
|
|
|
|
// get memory pool rendered template
|
|
|
|
// get memory pool rendered template
|
|
|
|
string mempool_html = mempool();
|
|
|
|
string mempool_html = mempool();
|
|
|
|