From 3b70ec976d7882b509ddf1d773fc12983231b438 Mon Sep 17 00:00:00 2001 From: Dan Janosik Date: Thu, 31 May 2018 23:47:00 -0400 Subject: [PATCH] cleanup for recent changes --- app/utils.js | 13 ++++++++++++- views/mempool-summary.pug | 9 ++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/utils.js b/app/utils.js index afb551a..ccd0f1d 100644 --- a/app/utils.js +++ b/app/utils.js @@ -96,6 +96,9 @@ function formatCurrencyAmount(amount, formatType) { dec = dec.times(formatCurrencyCache[formatType].multiplier); var decimalPlaces = formatCurrencyCache[formatType].decimalPlaces; + if (decimalPlaces == 0 && dec < 1) { + decimalPlaces = 5; + } return addThousandsSeparators(dec.toDecimalPlaces(decimalPlaces)) + " " + formatCurrencyCache[formatType].name; } @@ -113,6 +116,9 @@ function formatCurrencyAmount(amount, formatType) { dec = dec.times(currencyUnit.multiplier); var decimalPlaces = currencyUnit.decimalPlaces; + if (decimalPlaces == 0 && dec < 1) { + decimalPlaces = 5; + } return addThousandsSeparators(dec.toDecimalPlaces(decimalPlaces)) + " " + currencyUnit.name; } @@ -122,6 +128,10 @@ function formatCurrencyAmount(amount, formatType) { return amount; } +function formatCurrencyAmountInSmallestUnits(amount) { + return formatCurrencyAmount(amount, coins[env.coin].currencyUnits[coins[env.coin].currencyUnits.length - 1].name); +} + // ref: https://stackoverflow.com/a/2901298/673828 function addThousandsSeparators(x) { var parts = x.toString().split("."); @@ -151,5 +161,6 @@ module.exports = { formatBytes: formatBytes, formatCurrencyAmount: formatCurrencyAmount, formatExchangedCurrency: formatExchangedCurrency, - addThousandsSeparators: addThousandsSeparators + addThousandsSeparators: addThousandsSeparators, + formatCurrencyAmountInSmallestUnits: formatCurrencyAmountInSmallestUnits }; diff --git a/views/mempool-summary.pug b/views/mempool-summary.pug index b94b82f..918b558 100644 --- a/views/mempool-summary.pug +++ b/views/mempool-summary.pug @@ -39,7 +39,7 @@ block content tr th(class="table-active properties-header") Average Fee per Byte - td(class="monospace") #{(mempoolstats["averageFeePerByte"] * 100000000).toFixed(6)} sat/B + td(class="monospace") #{utils.formatCurrencyAmountInSmallestUnits(mempoolstats["averageFeePerByte"])}/B h4 Transactions by fee rate hr @@ -110,6 +110,9 @@ block content td(class="text-right monospace") #{item["count"].toLocaleString()} td(class="text-right monospace") #{utils.formatCurrencyAmount(item["totalFees"], currencyFormatType)} - - var avgFeeRate = item["totalFees"] * 100000000 / item["totalBytes"]; - td(class="text-right monospace") #{avgFeeRate.toFixed(2)} sat/B + 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