|
@ -258,34 +258,17 @@ function parseExponentStringDouble(val) { |
|
|
: lead + ( +pow >= decimal.length ? (decimal + "0".repeat(+pow-decimal.length)) : (decimal.slice(0,+pow)+"."+decimal.slice(+pow))); |
|
|
: lead + ( +pow >= decimal.length ? (decimal + "0".repeat(+pow-decimal.length)) : (decimal.slice(0,+pow)+"."+decimal.slice(+pow))); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function formatHashrate(val, decimalPlaces) { |
|
|
function formatLargeNumber(n, decimalPlaces) { |
|
|
console.log("formatting hashrate: " + val); |
|
|
|
|
|
|
|
|
|
|
|
var x = parseExponentStringDouble(val); |
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < exponentScales.length; i++) { |
|
|
|
|
|
var item = exponentScales[i]; |
|
|
|
|
|
|
|
|
|
|
|
var fraction = new Decimal(x / item.val); |
|
|
|
|
|
if (fraction >= 1) { |
|
|
|
|
|
return [fraction.toDecimalPlaces(decimalPlaces), item]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return [x, {}]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function formatDifficulty(d, decimalPlaces) { |
|
|
|
|
|
for (var i = 0; i < exponentScales.length; i++) { |
|
|
for (var i = 0; i < exponentScales.length; i++) { |
|
|
var item = exponentScales[i]; |
|
|
var item = exponentScales[i]; |
|
|
|
|
|
|
|
|
var fraction = new Decimal(d / item.val); |
|
|
var fraction = new Decimal(n / item.val); |
|
|
if (fraction >= 1) { |
|
|
if (fraction >= 1) { |
|
|
return [fraction.toDecimalPlaces(decimalPlaces), item]; |
|
|
return [fraction.toDecimalPlaces(decimalPlaces), item]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return [d, {}]; |
|
|
return [n, {}]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -306,6 +289,5 @@ module.exports = { |
|
|
getBlockTotalFeesFromCoinbaseTxAndBlockHeight: getBlockTotalFeesFromCoinbaseTxAndBlockHeight, |
|
|
getBlockTotalFeesFromCoinbaseTxAndBlockHeight: getBlockTotalFeesFromCoinbaseTxAndBlockHeight, |
|
|
refreshExchangeRate: refreshExchangeRate, |
|
|
refreshExchangeRate: refreshExchangeRate, |
|
|
parseExponentStringDouble: parseExponentStringDouble, |
|
|
parseExponentStringDouble: parseExponentStringDouble, |
|
|
formatHashrate: formatHashrate, |
|
|
formatLargeNumber: formatLargeNumber |
|
|
formatDifficulty: formatDifficulty |
|
|
|
|
|
}; |
|
|
}; |
|
|