Skip to content

Commit

Permalink
mempool summary ux improvements
Browse files Browse the repository at this point in the history
thanks for the suggestions @pointbiz
  • Loading branch information
janoside committed Apr 8, 2021
1 parent c63289f commit 0da0ef3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 1 addition & 3 deletions routes/apiRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,7 @@ router.get("/mempool-tx-summaries/:txids", asyncHandler(async (req, res, next) =
w: item.entry.weight ? item.entry.weight : item.entry.size * 4
};

mempoolTxSummaryCache[key] = itemSummary;

results.push(mempoolTxSummaryCache[key]);
results.push(itemSummary);

resolve();

Expand Down
18 changes: 13 additions & 5 deletions views/mempool-summary.pug
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ block content

form.form-inline(method="post", action="javascript:void(0)", onsubmit=`estimateTransactionMempoolDepth($("#mempoolquery").val()); return false;` style="width: 325px;")
.input-group.input-group
input.form-control.form-control(id="mempoolquery", type="text", name="mempoolquery", placeholder="txid", value=(mempoolquery))
input.form-control.form-control(id="mempoolquery", type="text", name="mempoolquery", placeholder="txid", value=(mempoolquery), title="<span class='text-warning'>Transaction not found</span>", data-bs-trigger="manual", data-bs-html="true", data-bs-placement="bottom")

button.btn.btn-primary(type="submit")
i.fas.fa-search
Expand Down Expand Up @@ -550,6 +550,9 @@ block endOfBody
};
}

var notfoundEl = document.getElementById("mempoolquery");
var notfoundTooltip = new bootstrap.Tooltip(notfoundEl);

function estimateTransactionMempoolDepth(txid) {
var avgTransactionsPerBlock = 3000;
var satsPerBitcoin = 100000000; // TODO: magic number - replace with coinConfig.baseCurrencyUnit.multiplier
Expand All @@ -558,12 +561,17 @@ block endOfBody
url: `./api/mempool-tx-summaries/${txid}`

}).done(function(resultList) {
if (resultList && resultList.length > 0) {
var result = resultList[0];

var result = resultList[0];
var feeRate = new Decimal(result.f).times(100000000).dividedBy(result.sz); // TODO: magic number, sat/BTC

var feeRate = new Decimal(result.f).times(100000000).dividedBy(result.sz); // TODO: magic number, sat/BTC
estimateMempoolDepth(feeRate);

estimateMempoolDepth(feeRate);
} else {
notfoundTooltip.show();
setTimeout(() => { notfoundTooltip.hide(); }, 2000);
}
});
}

Expand Down Expand Up @@ -601,7 +609,7 @@ block endOfBody
$("#estimate-mempooldepth").text(`~${minBlocks.toDP(1)}`);

} else {
$("#estimate-mempooldepth").text(`${minBlocks.toDP(1)} - ${maxBlocks.toDP(1)}`);
$("#estimate-mempooldepth").text(`${Math.floor(minBlocks)} - ${Math.ceil(maxBlocks)}`);
}

var minMinutes = minBlocks.times(10); // TODO: magic number: 10min
Expand Down

0 comments on commit 0da0ef3

Please sign in to comment.