From 4f15c6164d8f73e109ceb5844aa992a5d15365bc Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 9 Mar 2018 08:54:31 +0800 Subject: [PATCH] fee per kB added to transaction pool https://github.com/moneroexamples/onion-monero-blockchain-explorer/issues/107 --- src/MempoolStatus.cpp | 2 +- src/page.h | 8 ++++++-- src/templates/mempool.html | 8 ++++---- src/templates/partials/tx_details.html | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/MempoolStatus.cpp b/src/MempoolStatus.cpp index 56b807a..883a96f 100644 --- a/src/MempoolStatus.cpp +++ b/src/MempoolStatus.cpp @@ -169,7 +169,7 @@ MempoolStatus::read_mempool() last_tx.num_nonrct_inputs = sum_data[3]; last_tx.fee_str = xmreg::xmr_amount_to_str(_tx_info.fee, "{:0.3f}", false); - last_tx.payed_for_kB_str = fmt::format("{:0.3f}", payed_for_kB); + last_tx.payed_for_kB_str = fmt::format("{:0.4f}", payed_for_kB); last_tx.xmr_inputs_str = xmreg::xmr_amount_to_str(last_tx.sum_inputs , "{:0.3f}"); last_tx.xmr_outputs_str = xmreg::xmr_amount_to_str(last_tx.sum_outputs, "{:0.3f}"); last_tx.timestamp_str = xmreg::timestamp_to_str_gm(_tx_info.receive_time); diff --git a/src/page.h b/src/page.h index 982e151..36a7258 100644 --- a/src/page.h +++ b/src/page.h @@ -5573,6 +5573,10 @@ namespace xmreg // use this regex to remove all non friendly characters in payment_id_as_ascii string static std::regex e {"[^a-zA-Z0-9 ./\\\\!]"}; + double tx_size = static_cast(txd.size) / 1024.0; + + double payed_for_kB = XMR_AMOUNT(txd.fee) / tx_size; + // initalise page tempate map with basic info about blockchain mstch::map context { {"testnet" , testnet}, @@ -5582,9 +5586,9 @@ namespace xmreg {"tx_pub_key" , pod_to_hex(txd.pk)}, {"blk_height" , tx_blk_height_str}, {"tx_blk_height" , tx_blk_height}, - {"tx_size" , fmt::format("{:0.4f}", - static_cast(txd.size) / 1024.0)}, + {"tx_size" , fmt::format("{:0.4f}", tx_size)}, {"tx_fee" , xmreg::xmr_amount_to_str(txd.fee, "{:0.12f}", false)}, + {"payed_for_kB" , fmt::format("{:0.12f}", payed_for_kB)}, {"tx_version" , static_cast(txd.version)}, {"blk_timestamp" , blk_timestamp}, {"blk_timestamp_uint" , blk.timestamp}, diff --git a/src/templates/mempool.html b/src/templates/mempool.html index f508b2a..df9e2e1 100644 --- a/src/templates/mempool.html +++ b/src/templates/mempool.html @@ -8,8 +8,8 @@ age [h:m:s] transaction hash - fee - outputs + fee/per_kB + in/out/pID ring size tx size [kB] @@ -18,8 +18,8 @@ {{age}} {{hash}} - {{fee}} - {{xmr_outputs}} + {{fee}}/{{payed_for_kB}} + {{no_inputs}}/{{no_outputs}}/{{pID}} {{mixin}} {{txsize}} diff --git a/src/templates/partials/tx_details.html b/src/templates/partials/tx_details.html index 1032360..056eee7 100644 --- a/src/templates/partials/tx_details.html +++ b/src/templates/partials/tx_details.html @@ -38,7 +38,7 @@ {{/have_raw_tx}} Block: {{blk_height}} - Fee: {{tx_fee}} + Fee (per_kB): {{tx_fee}} ({{payed_for_kB}}) Tx size: {{tx_size}} kB