Responsive mempool blocks.

This commit is contained in:
softsimon
2020-03-12 21:56:07 +07:00
parent ff685e836a
commit 35569d5c45
7 changed files with 48 additions and 11 deletions

View File

@@ -73,8 +73,8 @@ class Blocks {
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];
block.medianFee = transactions.length > 1 ? this.median(transactions.map((tx) => tx.feePerVsize)) : 0;
block.feeRange = transactions.length > 1 ? this.getFeesInRange(transactions, 8) : [0, 0];
this.blocks.push(block);
if (this.blocks.length > config.KEEP_BLOCK_AMOUNT) {
@@ -111,7 +111,7 @@ class Blocks {
itemsToAdd--;
}
arr.push(transactions[0].feePerVsize);
arr.push(transactions[1].feePerVsize);
return arr;
}
}

View File

@@ -29,7 +29,7 @@ class MempoolBlocks {
let blockSize = 0;
let transactions: TransactionExtended[] = [];
transactionsSorted.forEach((tx) => {
if (blockWeight + tx.vsize < 1000000 || mempoolBlocks.length === config.DEFAULT_PROJECTED_BLOCKS_AMOUNT) {
if (blockWeight + tx.vsize < 1000000 || mempoolBlocks.length === config.DEFAULT_PROJECTED_BLOCKS_AMOUNT - 1) {
blockWeight += tx.vsize;
blockSize += tx.size;
transactions.push(tx);