Browse Source

include "first seen" on address pages

fix-133-memory-crash
Dan Janosik 6 years ago
parent
commit
90727ba40a
  1. 19
      routes/baseActionsRouter.js
  2. 19
      views/address.pug

19
routes/baseActionsRouter.js

@ -610,8 +610,16 @@ router.get("/address/:address", function(req, res) {
pagedTxids.push(txids[i]);
}
}
// always request the first txid; we'll use it to show "first seen" info for the address
pagedTxids.unshift(txidResult.result[0].tx_hash);
coreApi.getRawTransactionsWithInputs(pagedTxids).then(function(rawTxResult) {
// first result is always the earliest tx, but doesn't fit into the current paging;
// store it as firstSeenTransaction then remove from list
res.locals.firstSeenTransaction = rawTxResult.transactions[0];
rawTxResult.transactions.shift();
res.locals.transactions = rawTxResult.transactions;
res.locals.txInputsByTransaction = rawTxResult.txInputsByTransaction;
res.locals.blockHeightsByTxid = blockHeightsByTxid;
@ -666,6 +674,17 @@ router.get("/address/:address", function(req, res) {
reject(err);
});
}));
promises.push(new Promise(function(resolve, reject) {
coreApi.getBlockchainInfo().then(function(getblockchaininfo) {
res.locals.getblockchaininfo = getblockchaininfo;
resolve();
}).catch(function(err) {
reject(err);
});
}));
}
Promise.all(promises).catch(function(err) {

19
views/address.pug

@ -100,6 +100,25 @@ block content
div(class="summary-split-table-label") Witness Program
div(class="summary-split-table-content monospace") #{result.validateaddress.witness_program}
if (firstSeenTransaction)
div(class="row")
div(class="summary-split-table-label") First Seen
div(class="summary-split-table-content monospace")
if (getblockchaininfo)
span Block ##{(getblockchaininfo.blocks - firstSeenTransaction.confirmations).toLocaleString()}
else
a(href=("/block/" + firstSeenTransaction.blockhash)) #{firstSeenTransaction.blockhash}
br
span #{moment.utc(new Date(firstSeenTransaction.time * 1000)).format("Y-MM-DD HH:mm:ss")} utc
- var timeAgoTime = firstSeenTransaction.time;
include includes/time-ago.pug
if (false)
pre
code #{JSON.stringify(firstSeenTransaction)}
if (balance)
if (balance.conflictedResults)
div(class="row")

Loading…
Cancel
Save