From 58b565f65e9672af43c64d16b4afe7f52f322003 Mon Sep 17 00:00:00 2001 From: xcps Date: Sun, 4 Feb 2018 23:00:35 +0500 Subject: [PATCH] Confirmations calculation --- public/stylesheets/style.css | 2 +- routes/block.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index 53678e2..79e162d 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -9,7 +9,7 @@ body { } table td { - padding-right: 1em; + padding-right: .5em; } a { diff --git a/routes/block.js b/routes/block.js index e7d1cca..ea1dcc1 100644 --- a/routes/block.js +++ b/routes/block.js @@ -12,11 +12,17 @@ router.get('/:hash', async function(req, res, next) { include: { model: models.Transaction, }, - }) + }); if (block === null) { res.status(404).render('404'); return; } + const lastBlock = await models.Block.findOne({ + attributes: [ + [models.sequelize.fn('MAX', models.sequelize.col('height')), 'maxheight'] + ], + }); + block.dataValues.confirmations = lastBlock.dataValues.maxheight - block.height + 1; block.dataValues.time = block.time.toUTCString(); res.render('block', { block,