Browse Source

parse values as float before using toFixed (for node 8+)

master
R4SAS 5 years ago committed by R4SAS
parent
commit
34ecc7c156
  1. 2
      routes/block.js
  2. 2
      routes/index.js

2
routes/block.js

@ -28,7 +28,7 @@ router.get('/:hash', async function(req, res, next) { @@ -28,7 +28,7 @@ router.get('/:hash', async function(req, res, next) {
const block = blockInstance.toJSON();
block.confirmations = lastBlock.maxheight - block.height + 1;
block.time = block.time.toUTCString();
block.difficulty = block.difficulty.toFixed(8);
block.difficulty = parseFloat(block.difficulty).toFixed(8);
block.hashrate = block.hashrate.toLocaleString() + " H/s";
res.render('block', {
block,

2
routes/index.js

@ -24,7 +24,7 @@ router.get('/', async function(req, res, next) { @@ -24,7 +24,7 @@ router.get('/', async function(req, res, next) {
});
blocks.forEach(function(arrayItem) {
arrayItem.ago = arrayItem.time.toUTCString().substring(5);
arrayItem.difficulty = arrayItem.difficulty.toFixed(8);
arrayItem.difficulty = parseFloat(arrayItem.difficulty).toFixed(8);
arrayItem.hashrate = formatRate(arrayItem.hashrate, 4);
});
res.render('index', {

Loading…
Cancel
Save