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 8 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); console.log("getTransactionInputs: " + transaction.txid);
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var txids = []; var txids = [];
for (var i = 0; i < transaction.vin.length; i++) { for (var i = 0; i < transaction.vin.length; i++) {
if (i < inputLimit || inputLimit == 0) {
txids.push(transaction.vin[i].txid); txids.push(transaction.vin[i].txid);
} }
}
getRawTransactions(txids).then(function(inputTransactions) { getRawTransactions(txids).then(function(inputTransactions) {
resolve({ txid:transaction.txid, inputTransactions:inputTransactions }); resolve({ txid:transaction.txid, inputTransactions:inputTransactions });
@ -280,7 +282,7 @@ function getBlockData(rpcClient, blockHash, txLimit, txOffset) {
var transaction = transactions[i]; var transaction = transactions[i];
if (transaction) { 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)); - totalInputValue = totalInputValue.plus(new Decimal(vout.value));
span(class="monospace") #{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 tr
td td
td td

Loading…
Cancel
Save