mirror of
https://github.com/GOSTSec/gostexplr
synced 2025-01-29 16:04:32 +00:00
Remove confirmation for db, add confimations to transaction page
This commit is contained in:
parent
ab06b20949
commit
a186ca9ebf
@ -6,7 +6,6 @@ module.exports = (sequelize, DataTypes) => {
|
||||
primaryKey: true,
|
||||
},
|
||||
hash: DataTypes.STRING(64),
|
||||
confirmations: DataTypes.MEDIUMINT.UNSIGNED,
|
||||
size: DataTypes.MEDIUMINT.UNSIGNED,
|
||||
version: DataTypes.TINYINT.UNSIGNED,
|
||||
merkleroot: DataTypes.STRING(64),
|
||||
|
@ -21,6 +21,7 @@
|
||||
"cookie-parser": "~1.4.3",
|
||||
"debug": "~2.6.9",
|
||||
"express": "~4.15.5",
|
||||
"forever": "^0.15.3",
|
||||
"jade": "~1.11.0",
|
||||
"morgan": "~1.9.0",
|
||||
"mysql": "^2.15.0",
|
||||
|
@ -5,7 +5,7 @@ var router = express.Router();
|
||||
/* GET home page. */
|
||||
router.get('/:hash', async function(req, res, next) {
|
||||
const hash = encodeURI(req.params.hash);
|
||||
const block = await models.Block.findOne({
|
||||
const blockInstance = await models.Block.findOne({
|
||||
where: {
|
||||
hash,
|
||||
},
|
||||
@ -13,7 +13,7 @@ router.get('/:hash', async function(req, res, next) {
|
||||
model: models.Transaction,
|
||||
},
|
||||
});
|
||||
if (block === null) {
|
||||
if (blockInstance === null) {
|
||||
res.status(404).render('404');
|
||||
return;
|
||||
}
|
||||
@ -21,9 +21,11 @@ router.get('/:hash', async function(req, res, next) {
|
||||
attributes: [
|
||||
[models.sequelize.fn('MAX', models.sequelize.col('height')), 'maxheight']
|
||||
],
|
||||
raw: true,
|
||||
});
|
||||
block.dataValues.confirmations = lastBlock.dataValues.maxheight - block.height + 1;
|
||||
block.dataValues.time = block.time.toUTCString();
|
||||
const block = blockInstance.toJSON();
|
||||
block.confirmations = lastBlock.maxheight - block.height + 1;
|
||||
block.time = block.time.toUTCString();
|
||||
res.render('block', {
|
||||
block,
|
||||
});
|
||||
|
@ -11,7 +11,7 @@ router.get('/:txid', async function(req, res, next) {
|
||||
txid,
|
||||
},
|
||||
include: [{
|
||||
attributes: ['hash', 'time'],
|
||||
attributes: ['hash', 'time', 'height'],
|
||||
model: models.Block,
|
||||
},{
|
||||
model: models.Vout,
|
||||
@ -36,10 +36,18 @@ router.get('/:txid', async function(req, res, next) {
|
||||
});
|
||||
});
|
||||
});
|
||||
const lastBlock = await models.Block.findOne({
|
||||
attributes: [
|
||||
[models.sequelize.fn('MAX', models.sequelize.col('height')), 'maxheight']
|
||||
],
|
||||
raw: true,
|
||||
});
|
||||
const confirmations = lastBlock.maxheight - transaction.Block.height + 1;
|
||||
transaction.blockTime = transaction.Block.time.toUTCString();
|
||||
res.render('transaction', {
|
||||
transaction,
|
||||
vouts,
|
||||
confirmations,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -4,7 +4,7 @@ block content
|
||||
h3 Block
|
||||
|
||||
table
|
||||
each key in Object.keys(block.dataValues)
|
||||
each key in Object.keys(block)
|
||||
if (key === 'nextblockhash')
|
||||
tr
|
||||
td.capitalize #{key}
|
||||
|
@ -14,6 +14,9 @@ block content
|
||||
tr
|
||||
td Block time
|
||||
td #{transaction.blockTime}
|
||||
tr
|
||||
td Confirmations
|
||||
td #{confirmations}
|
||||
|
||||
h3 In
|
||||
if transaction.txtx.length
|
||||
|
Loading…
x
Reference in New Issue
Block a user