From d360a809726eb2c036b957986e04038f3a2f02f4 Mon Sep 17 00:00:00 2001 From: Dan Janosik Date: Sat, 2 Jun 2018 13:09:26 -0400 Subject: [PATCH] More work on mempool summary; cleanup and fixes for LTC --- app/coins/btc.js | 3 +- app/coins/ltc.js | 17 +++- app/rpcApi.js | 2 +- views/mempool-summary.pug | 164 ++++++++++++++++++++------------------ 4 files changed, 106 insertions(+), 80 deletions(-) diff --git a/app/coins/btc.js b/app/coins/btc.js index 8706cc8..8df79e6 100644 --- a/app/coins/btc.js +++ b/app/coins/btc.js @@ -32,10 +32,11 @@ module.exports = { { name:"sat", multiplier:100000000, - values:["sat"], + values:["sat", "satoshi"], decimalPlaces:0 } ], + feeSatoshiPerByteBucketMaxima: [1, 5, 10, 15, 20, 25, 50, 75, 100, 150], genesisBlockHash: "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f", genesisCoinbaseTransactionId: "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b", genesisCoinbaseTransaction: { diff --git a/app/coins/ltc.js b/app/coins/ltc.js index f7085be..b1ef10e 100644 --- a/app/coins/ltc.js +++ b/app/coins/ltc.js @@ -17,12 +17,25 @@ module.exports = { decimalPlaces:8 }, { - name:"mLTC", + name:"lite", multiplier:1000, - values:["mltc"], + values:["lite"], decimalPlaces:5 + }, + { + name:"photon", + multiplier:1000000, + values:["photon"], + decimalPlaces:2 + }, + { + name:"litoshi", + multiplier:100000000, + values:["litoshi", "lit"], + decimalPlaces:0 } ], + feeSatoshiPerByteBucketMaxima: [5, 10, 25, 50, 100, 150, 200, 250], genesisBlockHash: "12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2", genesisCoinbaseTransactionId: "97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9", genesisCoinbaseTransaction: { diff --git a/app/rpcApi.js b/app/rpcApi.js index 018baf7..c15dc52 100644 --- a/app/rpcApi.js +++ b/app/rpcApi.js @@ -120,7 +120,7 @@ function getMempoolStats() { } } - var satoshiPerByteBucketMaxima = [1, 5, 10, 15, 20, 25, 50, 75, 100, 150]; + var satoshiPerByteBucketMaxima = coins[env.coin].feeSatoshiPerByteBucketMaxima; var bucketCount = satoshiPerByteBucketMaxima.length + 1; var satoshiPerByteBuckets = []; diff --git a/views/mempool-summary.pug b/views/mempool-summary.pug index 918b558..9623345 100644 --- a/views/mempool-summary.pug +++ b/views/mempool-summary.pug @@ -29,90 +29,102 @@ block content span(data-toggle="tooltip", title=utils.formatExchangedCurrency(mempoolstats["totalFees"])) i(class="fas fa-exchange-alt") - tr - th(class="table-active properties-header") Average Fee - td(class="monospace") #{utils.formatCurrencyAmount(mempoolstats["averageFee"], currencyFormatType)} - if (global.exchangeRate) - span - span(data-toggle="tooltip", title=utils.formatExchangedCurrency(mempoolstats["averageFee"])) - i(class="fas fa-exchange-alt") + if (getmempoolinfo.size > 0) + tr + th(class="table-active properties-header") Average Fee + td(class="monospace") #{utils.formatCurrencyAmount(mempoolstats["averageFee"], currencyFormatType)} + if (global.exchangeRate) + span + span(data-toggle="tooltip", title=utils.formatExchangedCurrency(mempoolstats["averageFee"])) + i(class="fas fa-exchange-alt") - tr - th(class="table-active properties-header") Average Fee per Byte - td(class="monospace") #{utils.formatCurrencyAmountInSmallestUnits(mempoolstats["averageFeePerByte"])}/B + tr + th(class="table-active properties-header") Average Fee per Byte + td(class="monospace") #{utils.formatCurrencyAmountInSmallestUnits(mempoolstats["averageFeePerByte"])}/B - h4 Transactions by fee rate - hr + if (getmempoolinfo.size > 0) + h4 Transactions by fee rate + hr - if (false) - #{JSON.stringify(mempoolstats)} + if (false) + #{JSON.stringify(mempoolstats)} - if (true) - - var feeBucketLabels = [("[0 - " + mempoolstats["satoshiPerByteBucketMaxima"][0] + ")")]; - each item, index in mempoolstats["satoshiPerByteBuckets"] - if (index > 0 && index < mempoolstats["satoshiPerByteBuckets"].length - 1) - - feeBucketLabels.push(("[" + mempoolstats["satoshiPerByteBucketMaxima"][index - 1] + " - " + mempoolstats["satoshiPerByteBucketMaxima"][index] + ")")); - - - feeBucketLabels.push((mempoolstats.satoshiPerByteBucketMaxima[mempoolstats.satoshiPerByteBucketMaxima.length - 1] + "+")); - - - var feeBucketTxCounts = mempoolstats["satoshiPerByteBucketCounts"]; - - var totalfeeBuckets = mempoolstats["satoshiPerByteBucketTotalFees"]; - - canvas(id="mempoolBarChart", height="100", class="mb-4") + if (true) + - var feeBucketLabels = [("[0 - " + mempoolstats["satoshiPerByteBucketMaxima"][0] + ")")]; + each item, index in mempoolstats["satoshiPerByteBuckets"] + if (index > 0 && index < mempoolstats["satoshiPerByteBuckets"].length - 1) + - feeBucketLabels.push(("[" + mempoolstats["satoshiPerByteBucketMaxima"][index - 1] + " - " + mempoolstats["satoshiPerByteBucketMaxima"][index] + ")")); + + - feeBucketLabels.push((mempoolstats.satoshiPerByteBucketMaxima[mempoolstats.satoshiPerByteBucketMaxima.length - 1] + "+")); + + - var feeBucketTxCounts = mempoolstats["satoshiPerByteBucketCounts"]; + - var totalfeeBuckets = mempoolstats["satoshiPerByteBucketTotalFees"]; + + canvas(id="mempoolBarChart", height="100", class="mb-4") - script(src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js") + script(src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js") - script var feeBucketLabels = []; - script var bgColors = []; - each feeBucketLabel, index in feeBucketLabels - - var percentTx = Math.round(100 * feeBucketTxCounts[index] / getmempoolinfo.size).toLocaleString(); - script feeBucketLabels.push(["#{feeBucketLabel}","#{feeBucketTxCounts[index]} tx (#{percentTx}%)"]); - script bgColors.push("hsl(#{(333 * index / feeBucketLabels.length)}, 100%, 50%)"); + script var feeBucketLabels = []; + script var bgColors = []; + each feeBucketLabel, index in feeBucketLabels + - var percentTx = Math.round(100 * feeBucketTxCounts[index] / getmempoolinfo.size).toLocaleString(); + script feeBucketLabels.push(["#{feeBucketLabel}","#{feeBucketTxCounts[index]} tx (#{percentTx}%)"]); + script bgColors.push("hsl(#{(333 * index / feeBucketLabels.length)}, 100%, 50%)"); - script var feeBucketTxCounts = [#{feeBucketTxCounts}]; + script var feeBucketTxCounts = [#{feeBucketTxCounts}]; - script. - var ctx = document.getElementById("mempoolBarChart").getContext('2d'); - var mempoolBarChart = new Chart(ctx, { - type: 'bar', - data: { - labels: feeBucketLabels, - datasets: [{ - data: feeBucketTxCounts, - backgroundColor: bgColors - }] - }, - options: { - legend: { - display: false - }, - scales: { - yAxes: [{ - ticks: { - beginAtZero:true - } - }] - } - } - }); + script. + var ctx = document.getElementById("mempoolBarChart").getContext('2d'); + var mempoolBarChart = new Chart(ctx, { + type: 'bar', + data: { + labels: feeBucketLabels, + datasets: [{ + data: feeBucketTxCounts, + backgroundColor: bgColors + }] + }, + options: { + legend: { + display: false + }, + scales: { + yAxes: [{ + ticks: { + beginAtZero:true + } + }] + } + } + }); - table(class="table table-striped table-responsive-sm") - thead - tr - th Fee Rate - th(class="text-right") Tx Count - th(class="text-right") Total Fees - th(class="text-right") Average Fee Rate - tbody - each item, index in mempoolstats["satoshiPerByteBuckets"] + table(class="table table-striped table-responsive-sm") + thead tr - td #{mempoolstats["satoshiPerByteBucketLabels"][index]} - td(class="text-right monospace") #{item["count"].toLocaleString()} - td(class="text-right monospace") #{utils.formatCurrencyAmount(item["totalFees"], currencyFormatType)} + th Fee Rate + th(class="text-right") Tx Count + th(class="text-right") Total Fees + th(class="text-right") Average Fee + th(class="text-right") Average Fee Rate + tbody + each item, index in mempoolstats["satoshiPerByteBuckets"] + tr + td #{mempoolstats["satoshiPerByteBucketLabels"][index]} + td(class="text-right monospace") #{item["count"].toLocaleString()} + td(class="text-right monospace") #{utils.formatCurrencyAmount(item["totalFees"], currencyFormatType)} + + if (item["totalBytes"] > 0) + - var avgFee = item["totalFees"] / item["count"]; + - var avgFeeRate = item["totalFees"] / item["totalBytes"]; - if (item["totalBytes"] > 0) - - var avgFeeRate = item["totalFees"] / item["totalBytes"]; - td(class="text-right monospace") #{utils.formatCurrencyAmountInSmallestUnits(avgFeeRate)}/B - else - td(class="text-right monospace") - - \ No newline at end of file + td(class="text-right monospace") #{utils.formatCurrencyAmount(avgFee, currencyFormatType)} + if (global.exchangeRate) + span + span(data-toggle="tooltip", title=utils.formatExchangedCurrency(avgFee)) + i(class="fas fa-exchange-alt") + + td(class="text-right monospace") #{utils.formatCurrencyAmountInSmallestUnits(avgFeeRate)}/B + else + td(class="text-right monospace") - + td(class="text-right monospace") - + \ No newline at end of file