Browse Source

cleanup for recent changes

fix-133-memory-crash
Dan Janosik 7 years ago
parent
commit
3b70ec976d
  1. 13
      app/utils.js
  2. 9
      views/mempool-summary.pug

13
app/utils.js

@ -96,6 +96,9 @@ function formatCurrencyAmount(amount, formatType) {
dec = dec.times(formatCurrencyCache[formatType].multiplier); dec = dec.times(formatCurrencyCache[formatType].multiplier);
var decimalPlaces = formatCurrencyCache[formatType].decimalPlaces; var decimalPlaces = formatCurrencyCache[formatType].decimalPlaces;
if (decimalPlaces == 0 && dec < 1) {
decimalPlaces = 5;
}
return addThousandsSeparators(dec.toDecimalPlaces(decimalPlaces)) + " " + formatCurrencyCache[formatType].name; return addThousandsSeparators(dec.toDecimalPlaces(decimalPlaces)) + " " + formatCurrencyCache[formatType].name;
} }
@ -113,6 +116,9 @@ function formatCurrencyAmount(amount, formatType) {
dec = dec.times(currencyUnit.multiplier); dec = dec.times(currencyUnit.multiplier);
var decimalPlaces = currencyUnit.decimalPlaces; var decimalPlaces = currencyUnit.decimalPlaces;
if (decimalPlaces == 0 && dec < 1) {
decimalPlaces = 5;
}
return addThousandsSeparators(dec.toDecimalPlaces(decimalPlaces)) + " " + currencyUnit.name; return addThousandsSeparators(dec.toDecimalPlaces(decimalPlaces)) + " " + currencyUnit.name;
} }
@ -122,6 +128,10 @@ function formatCurrencyAmount(amount, formatType) {
return amount; 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 // ref: https://stackoverflow.com/a/2901298/673828
function addThousandsSeparators(x) { function addThousandsSeparators(x) {
var parts = x.toString().split("."); var parts = x.toString().split(".");
@ -151,5 +161,6 @@ module.exports = {
formatBytes: formatBytes, formatBytes: formatBytes,
formatCurrencyAmount: formatCurrencyAmount, formatCurrencyAmount: formatCurrencyAmount,
formatExchangedCurrency: formatExchangedCurrency, formatExchangedCurrency: formatExchangedCurrency,
addThousandsSeparators: addThousandsSeparators addThousandsSeparators: addThousandsSeparators,
formatCurrencyAmountInSmallestUnits: formatCurrencyAmountInSmallestUnits
}; };

9
views/mempool-summary.pug

@ -39,7 +39,7 @@ block content
tr tr
th(class="table-active properties-header") Average Fee per Byte 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 h4 Transactions by fee rate
hr hr
@ -110,6 +110,9 @@ block content
td(class="text-right monospace") #{item["count"].toLocaleString()} td(class="text-right monospace") #{item["count"].toLocaleString()}
td(class="text-right monospace") #{utils.formatCurrencyAmount(item["totalFees"], currencyFormatType)} td(class="text-right monospace") #{utils.formatCurrencyAmount(item["totalFees"], currencyFormatType)}
- var avgFeeRate = item["totalFees"] * 100000000 / item["totalBytes"]; if (item["totalBytes"] > 0)
td(class="text-right monospace") #{avgFeeRate.toFixed(2)} sat/B - var avgFeeRate = item["totalFees"] / item["totalBytes"];
td(class="text-right monospace") #{utils.formatCurrencyAmountInSmallestUnits(avgFeeRate)}/B
else
td(class="text-right monospace") -
Loading…
Cancel
Save