Browse Source

- more style consistency

- 2 decimal places for fee/byte on mempool summary
fix-133-memory-crash
Dan Janosik 6 years ago
parent
commit
20f1dc2f44
  1. 19
      app/utils.js
  2. 70
      views/mempool-summary.pug
  3. 2
      views/node-status.pug
  4. 2
      views/transaction.pug

19
app/utils.js

@ -83,7 +83,7 @@ function getRandomString(length, chars) {
var formatCurrencyCache = {};
function formatCurrencyAmount(amount, formatType) {
function formatCurrencyAmountWithForcedDecimalPlaces(amount, formatType, forcedDecimalPlaces) {
if (formatCurrencyCache[formatType]) {
var dec = new Decimal(amount);
dec = dec.times(formatCurrencyCache[formatType].multiplier);
@ -93,6 +93,10 @@ function formatCurrencyAmount(amount, formatType) {
decimalPlaces = 5;
}
if (forcedDecimalPlaces >= 0) {
decimalPlaces = forcedDecimalPlaces;
}
return addThousandsSeparators(dec.toDecimalPlaces(decimalPlaces)) + " " + formatCurrencyCache[formatType].name;
}
@ -113,6 +117,10 @@ function formatCurrencyAmount(amount, formatType) {
decimalPlaces = 5;
}
if (forcedDecimalPlaces >= 0) {
decimalPlaces = forcedDecimalPlaces;
}
return addThousandsSeparators(dec.toDecimalPlaces(decimalPlaces)) + " " + currencyUnit.name;
}
}
@ -121,8 +129,12 @@ function formatCurrencyAmount(amount, formatType) {
return amount;
}
function formatCurrencyAmountInSmallestUnits(amount) {
return formatCurrencyAmount(amount, coins[config.coin].currencyUnits[coins[config.coin].currencyUnits.length - 1].name);
function formatCurrencyAmount(amount, formatType) {
return formatCurrencyAmountWithForcedDecimalPlaces(amount, formatType, -1);
}
function formatCurrencyAmountInSmallestUnits(amount, forcedDecimalPlaces) {
return formatCurrencyAmountWithForcedDecimalPlaces(amount, coins[config.coin].currencyUnits[coins[config.coin].currencyUnits.length - 1].name, forcedDecimalPlaces);
}
// ref: https://stackoverflow.com/a/2901298/673828
@ -336,6 +348,7 @@ module.exports = {
splitArrayIntoChunks: splitArrayIntoChunks,
getRandomString: getRandomString,
formatCurrencyAmount: formatCurrencyAmount,
formatCurrencyAmountWithForcedDecimalPlaces: formatCurrencyAmountWithForcedDecimalPlaces,
formatExchangedCurrency: formatExchangedCurrency,
addThousandsSeparators: addThousandsSeparators,
formatCurrencyAmountInSmallestUnits: formatCurrencyAmountInSmallestUnits,

70
views/mempool-summary.pug

@ -12,38 +12,42 @@ block content
code #{JSON.stringify(mempoolstats, null, 4)}
if (true)
table(class="table")
tr
th(class="table-active properties-header") Transaction Count
td #{getmempoolinfo.size.toLocaleString()}
tr
- var mem1Data = utils.formatLargeNumber(getmempoolinfo.usage, 2);
- var mem2Data = utils.formatLargeNumber(getmempoolinfo.bytes, 2);
th(class="table-active properties-header") Memory Usage
td(class="monospace")
span #{mem1Data[0]} #{mem1Data[1].abbreviation}B
span(class="text-muted") (virtual size: #{mem2Data[0]} #{mem2Data[1].abbreviation}B)
tr
th(class="table-active properties-header") Total Fees
td(class="monospace")
- var currencyValue = mempoolstats["totalFees"];
include includes/value-display.pug
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
div(class="card mb-3")
div(class="card-header")
span(class="h6") Summary
div(class="card-body")
table(class="table details-table mb-0")
tr
td(class="properties-header") Transaction Count
td #{getmempoolinfo.size.toLocaleString()}
tr
- var mem1Data = utils.formatLargeNumber(getmempoolinfo.usage, 2);
- var mem2Data = utils.formatLargeNumber(getmempoolinfo.bytes, 2);
td(class="properties-header") Memory Usage
td(class="monospace")
span #{mem1Data[0]} #{mem1Data[1].abbreviation}B
span(class="text-muted") (virtual size: #{mem2Data[0]} #{mem2Data[1].abbreviation}B)
tr
td(class="properties-header") Total Fees
td(class="monospace")
- var currencyValue = mempoolstats["totalFees"];
include includes/value-display.pug
if (getmempoolinfo.size > 0)
tr
td(class="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
td(class="properties-header") Average Fee per Byte
td(class="monospace") #{utils.formatCurrencyAmountInSmallestUnits(mempoolstats["averageFeePerByte"], 2)}/B
if (getmempoolinfo.size > 0)
h2(class="h5") Transactions by fee rate
@ -126,7 +130,7 @@ block content
span(data-toggle="tooltip", title=utils.formatExchangedCurrency(avgFee))
i(class="fas fa-exchange-alt")
td(class="text-right monospace") #{utils.formatCurrencyAmountInSmallestUnits(avgFeeRate)}/B
td(class="text-right monospace") #{utils.formatCurrencyAmountInSmallestUnits(avgFeeRate, 2)}/B
else
td(class="text-right monospace") -
td(class="text-right monospace") -

2
views/node-status.pug

@ -25,7 +25,7 @@ block content
div(class="card-header")
span(class="h6") Summary
div(class="card-body")
table(class="table details-table")
table(class="table details-table mb-0")
tr
td(class="properties-header") Host : Port
td(class="monospace") #{global.client.host + " : " + global.client.port}

2
views/transaction.pug

@ -180,7 +180,7 @@ block content
br
span(class="text-muted") (#{utils.formatCurrencyAmount(totalInputValue, currencyFormatType)} - #{utils.formatCurrencyAmount(totalOutputValue, currencyFormatType)})
br
span ~#{utils.addThousandsSeparators(new DecimalRounded(totalInputValue).minus(totalOutputValue).dividedBy(result.getrawtransaction.size).times(100000000))} sat/B
span #{utils.addThousandsSeparators(new DecimalRounded(totalInputValue).minus(totalOutputValue).dividedBy(result.getrawtransaction.size).times(100000000))} sat/B
if (result.getrawtransaction.vin[0].coinbase)
div(class="card mb-3")

Loading…
Cancel
Save