Merge pull request #1277 from nymkappa/feature/mempool-show-only-fees

Remove block subsidy from mempool blocks
This commit is contained in:
wiz 2022-02-23 02:55:03 +00:00 committed by GitHub
commit c52f1c6973
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 16 deletions

View File

@ -116,6 +116,9 @@ class Blocks {
Common.median(transactionsTmp.map((tx) => tx.effectiveFeePerVsize)) : 0;
blockExtended.extras.feeRange = transactionsTmp.length > 0 ?
Common.getFeesInRange(transactionsTmp, 8) : [0, 0];
blockExtended.extras.totalFees = transactionsTmp.reduce((acc, tx) => {
return acc + tx.fee;
}, 0)
if (Common.indexingEnabled()) {
let pool: PoolTag;

View File

@ -78,6 +78,7 @@ export interface TransactionStripped {
}
export interface BlockExtension {
totalFees?: number;
medianFee?: number;
feeRange?: number[];
reward?: number;

View File

@ -14,7 +14,7 @@
{{ block?.extras?.feeRange[1] | number:feeRounding }} - {{ block?.extras?.feeRange[block?.extras?.feeRange.length - 1] | number:feeRounding }} <ng-container i18n="shared.sat-vbyte|sat/vB">sat/vB</ng-container>
</div>
<div *ngIf="showMiningInfo" class="block-size">
<app-amount [satoshis]="block.extras.reward" digitsInfo="1.2-2" [noFiat]="true"></app-amount>
<app-amount [satoshis]="block.extras?.totalFees ?? 0" digitsInfo="1.2-3" [noFiat]="true"></app-amount>
</div>
<div *ngIf="!showMiningInfo" class="block-size" [innerHTML]="'&lrm;' + (block.size | bytes: 2)"></div>
<div class="transaction-count">

View File

@ -13,7 +13,7 @@
{{ projectedBlock.feeRange[0] | number:feeRounding }} - {{ projectedBlock.feeRange[projectedBlock.feeRange.length - 1] | number:feeRounding }} <span i18n="shared.sat-vbyte|sat/vB">sat/vB</span>
</div>
<div *ngIf="showMiningInfo" class="block-size">
<app-amount [satoshis]="projectedBlock.totalFees + blockSubsidy * 100000000" digitsInfo="1.2-2" [noFiat]="true"></app-amount>
<app-amount [satoshis]="projectedBlock.totalFees" digitsInfo="1.2-3" [noFiat]="true"></app-amount>
</div>
<div *ngIf="!showMiningInfo" class="block-size" [innerHTML]="'&lrm;' + (projectedBlock.blockSize | bytes: 2)"></div>
<div class="transaction-count">

View File

@ -34,7 +34,6 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
network = '';
now = new Date().getTime();
showMiningInfo = false;
blockSubsidy = 50;
blockWidth = 125;
blockPadding = 30;
@ -111,7 +110,6 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
if (this.stateService.network === '') {
block.blink = specialBlocks[block.height] ? true : false;
}
this.setBlockSubsidy(block.height);
});
const stringifiedBlocks = JSON.stringify(mempoolBlocks);
@ -212,18 +210,6 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
return block.index;
}
setBlockSubsidy(blockHeight) {
if (!['', 'testnet', 'signet'].includes(this.stateService.network)) {
return;
}
this.blockSubsidy = 50;
let halvenings = Math.floor(blockHeight / 210000);
while (halvenings > 0) {
this.blockSubsidy = this.blockSubsidy / 2;
halvenings--;
}
}
reduceMempoolBlocksToFitScreen(blocks: MempoolBlock[]): MempoolBlock[] {
const innerWidth = this.stateService.env.BASE_MODULE !== 'liquid' && window.innerWidth <= 767.98 ? window.innerWidth : window.innerWidth / 2;
const blocksAmount = Math.min(this.stateService.env.MEMPOOL_BLOCKS_AMOUNT, Math.floor(innerWidth / (this.blockWidth + this.blockPadding)));

View File

@ -101,6 +101,7 @@ export interface PoolStat {
}
export interface BlockExtension {
totalFees?: number;
medianFee?: number;
feeRange?: number[];
reward?: number;