Browse Source

When viewing block detail, summarize tx inputs to the first 10 for performance

User can always navigate to the tx detail page to see everything
fix-133-memory-crash
Dan Janosik 7 years ago
parent
commit
e0bd1e11ac
  1. 6
      app/rpcApi.js
  2. 7
      views/includes/block-content.pug

6
app/rpcApi.js

@ -138,14 +138,16 @@ function getBlockByHash(blockHash) {
});
}
function getTransactionInputs(rpcClient, transaction) {
function getTransactionInputs(rpcClient, transaction, inputLimit=0) {
console.log("getTransactionInputs: " + transaction.txid);
return new Promise(function(resolve, reject) {
var txids = [];
for (var i = 0; i < transaction.vin.length; i++) {
if (i < inputLimit || inputLimit == 0) {
txids.push(transaction.vin[i].txid);
}
}
getRawTransactions(txids).then(function(inputTransactions) {
resolve({ txid:transaction.txid, inputTransactions:inputTransactions });
@ -280,7 +282,7 @@ function getBlockData(rpcClient, blockHash, txLimit, txOffset) {
var transaction = transactions[i];
if (transaction) {
promises.push(getTransactionInputs(client, transaction));
promises.push(getTransactionInputs(client, transaction, 10));
}
}

7
views/includes/block-content.pug

@ -163,6 +163,13 @@ div(class="tab-content")
- totalInputValue = totalInputValue.plus(new Decimal(vout.value));
span(class="monospace") #{vout.value}
if (tx.vin.length > result.txInputsByTransaction[tx.txid].length)
tr
td
td
span(class="monospace text-muted") #{(tx.vin.length - result.txInputsByTransaction[tx.txid].length).toLocaleString()} more...
td
else
tr
td
td

Loading…
Cancel
Save