diff --git a/app/utils.js b/app/utils.js index c0ba002..c06d535 100644 --- a/app/utils.js +++ b/app/utils.js @@ -81,20 +81,6 @@ function getRandomString(length, chars) { return result; } -function formatBytes(bytesInt) { - var scales = [ {val:1000000000000000, name:"PB"}, {val:1000000000000, name:"TB"}, {val:1000000000, name:"GB"}, {val:1000000, name:"MB"}, {val:1000, name:"KB"} ]; - for (var i = 0; i < scales.length; i++) { - var item = scales[i]; - - var fraction = Math.floor(bytesInt / item.val); - if (fraction >= 1) { - return fraction.toLocaleString() + " " + item.name; - } - } - - return Math.floor(bytesInt) + " B"; -} - var formatCurrencyCache = {}; function formatCurrencyAmount(amount, formatType) { @@ -345,7 +331,6 @@ module.exports = { hex2ascii: hex2ascii, splitArrayIntoChunks: splitArrayIntoChunks, getRandomString: getRandomString, - formatBytes: formatBytes, formatCurrencyAmount: formatCurrencyAmount, formatExchangedCurrency: formatExchangedCurrency, addThousandsSeparators: addThousandsSeparators, diff --git a/views/mempool-summary.pug b/views/mempool-summary.pug index 32cba49..66c05ed 100644 --- a/views/mempool-summary.pug +++ b/views/mempool-summary.pug @@ -16,11 +16,16 @@ block content 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 #{utils.formatBytes(getmempoolinfo.usage)} - span(class="text-muted") (virtual size: #{utils.formatBytes(getmempoolinfo.bytes)}) + 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") diff --git a/views/node-status.pug b/views/node-status.pug index 1eac919..3dd123d 100644 --- a/views/node-status.pug +++ b/views/node-status.pug @@ -37,9 +37,10 @@ block content td(class="monospace") #{getnetworkinfo.protocolversion} if (getblockchaininfo.size_on_disk) + - var sizeData = utils.formatLargeNumber(getblockchaininfo.size_on_disk, 2); tr th(class="table-active properties-header") Blockchain Size - td(class="monospace") #{utils.formatBytes(getblockchaininfo.size_on_disk)} + td(class="monospace") #{sizeData[0]} #{sizeData[1].abbreviation}B br span(class="text-muted") (pruned: #{getblockchaininfo.pruned}) tr @@ -78,11 +79,16 @@ block content tr th(class="table-active properties-header") Network Traffic td(class="monospace") - span Total Download: #{utils.formatBytes(getnettotals.totalbytesrecv)} - span(class="text-muted") (avg #{utils.formatBytes(getnettotals.totalbytesrecv / uptimeSeconds)}/s) + - var downData = utils.formatLargeNumber(getnettotals.totalbytesrecv, 2); + - var downRateData = utils.formatLargeNumber(getnettotals.totalbytesrecv / uptimeSeconds, 2); + - var upData = utils.formatLargeNumber(getnettotals.totalbytessent, 2); + - var upRateData = utils.formatLargeNumber(getnettotals.totalbytessent / uptimeSeconds, 2); + + span Total Download: #{downData[0]} #{downData[1].abbreviation}B + span(class="text-muted") (avg #{downRateData[0]} #{downRateData[1].abbreviation}B/s) br - span Total Upload: #{utils.formatBytes(getnettotals.totalbytessent)} - span(class="text-muted") (avg #{utils.formatBytes(getnettotals.totalbytessent / uptimeSeconds)}/s) + span Total Upload: #{upData[0]} #{upData[1].abbreviation}B + span(class="text-muted") (avg #{upRateData[0]} #{upRateData[1].abbreviation}B/s) tr(class="border-bottom") th(class="table-active properties-header") Warnings