Adding miner block reward and fee to block info.

This commit is contained in:
softsimon
2020-03-04 15:10:30 +07:00
parent f71ac67d24
commit 73e24195da
5 changed files with 37 additions and 11 deletions

View File

@@ -55,7 +55,7 @@ class Blocks {
const transactions: TransactionExtended[] = [];
for (let i = 1; i < txIds.length; i++) {
for (let i = 0; i < txIds.length; i++) {
if (mempool[txIds[i]]) {
transactions.push(mempool[txIds[i]]);
found++;
@@ -71,6 +71,7 @@ class Blocks {
console.log(`${found} of ${txIds.length} found in mempool. ${notFound} not found.`);
block.reward = transactions[0].vout.reduce((acc, curr) => acc + curr.value, 0);
transactions.sort((a, b) => b.feePerVsize - a.feePerVsize);
block.medianFee = transactions.length ? this.median(transactions.map((tx) => tx.feePerVsize)) : 0;
block.feeRange = transactions.length ? this.getFeesInRange(transactions, 8) : [0, 0];