From ee39283241d35120f23c0210c2a108edf8ea8c20 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Thu, 15 Jun 2023 09:45:25 -0400 Subject: [PATCH] precompute block fee spans --- frontend/src/app/components/block/block.component.html | 2 +- frontend/src/app/components/block/block.component.ts | 4 ++++ .../blockchain-blocks/blockchain-blocks.component.html | 5 ++--- .../blockchain-blocks/blockchain-blocks.component.ts | 9 +++++++++ frontend/src/app/interfaces/node-api.interface.ts | 2 ++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/components/block/block.component.html b/frontend/src/app/components/block/block.component.html index 14635f005..981ba494a 100644 --- a/frontend/src/app/components/block/block.component.html +++ b/frontend/src/app/components/block/block.component.html @@ -121,7 +121,7 @@ Fee span - {{ getMinBlockFee(block) | number:'1.0-0' }} - {{ getMaxBlockFee(block) | number:'1.0-0' }} sat/vB + {{ block?.extras?.minFee | number:'1.0-0' }} - {{ block?.extras?.maxFee | number:'1.0-0' }} sat/vB Median fee diff --git a/frontend/src/app/components/block/block.component.ts b/frontend/src/app/components/block/block.component.ts index 7f156eeb9..c2c2c583b 100644 --- a/frontend/src/app/components/block/block.component.ts +++ b/frontend/src/app/components/block/block.component.ts @@ -138,6 +138,8 @@ export class BlockComponent implements OnInit, OnDestroy { if (block.id === this.blockHash) { this.block = block; + block.extras.minFee = this.getMinBlockFee(block); + block.extras.maxFee = this.getMaxBlockFee(block); if (block?.extras?.reward != undefined) { this.fees = block.extras.reward / 100000000 - this.blockSubsidy; } @@ -234,6 +236,8 @@ export class BlockComponent implements OnInit, OnDestroy { } this.updateAuditAvailableFromBlockHeight(block.height); this.block = block; + block.extras.minFee = this.getMinBlockFee(block); + block.extras.maxFee = this.getMaxBlockFee(block); this.blockHeight = block.height; this.lastBlockHeight = this.blockHeight; this.nextBlockHeight = block.height + 1; diff --git a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html index 3c26cb0fd..d9518b1fa 100644 --- a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html +++ b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html @@ -31,9 +31,8 @@
- {{ getMinBlockFee(block) | number:feeRounding }} - {{ - getMaxBlockFee(block) | number:feeRounding }} + {{ block.extras.minFee | number:feeRounding }} - {{ block.extras.maxFee | number:feeRounding }} sat/vB
diff --git a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts index c1aaa0c63..eebf417a7 100644 --- a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts +++ b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts @@ -113,6 +113,9 @@ export class BlockchainBlocksComponent implements OnInit, OnChanges, OnDestroy { this.blocksFilled = false; } + block.extras.minFee = this.getMinBlockFee(block); + block.extras.maxFee = this.getMaxBlockFee(block); + this.blocks.unshift(block); this.blocks = this.blocks.slice(0, this.dynamicBlocksAmount); @@ -239,6 +242,10 @@ export class BlockchainBlocksComponent implements OnInit, OnChanges, OnDestroy { if (height >= 0) { this.cacheService.loadBlock(height); block = this.cacheService.getCachedBlock(height) || null; + if (block) { + block.extras.minFee = this.getMinBlockFee(block); + block.extras.maxFee = this.getMaxBlockFee(block); + } } this.blocks.push(block || { placeholder: height < 0, @@ -277,6 +284,8 @@ export class BlockchainBlocksComponent implements OnInit, OnChanges, OnDestroy { onBlockLoaded(block: BlockExtended) { const blockIndex = this.height - block.height; if (blockIndex >= 0 && blockIndex < this.blocks.length) { + block.extras.minFee = this.getMinBlockFee(block); + block.extras.maxFee = this.getMaxBlockFee(block); this.blocks[blockIndex] = block; this.blockStyles[blockIndex] = this.getStyleForBlock(block, blockIndex); } diff --git a/frontend/src/app/interfaces/node-api.interface.ts b/frontend/src/app/interfaces/node-api.interface.ts index a2e7b6537..c2aaf1151 100644 --- a/frontend/src/app/interfaces/node-api.interface.ts +++ b/frontend/src/app/interfaces/node-api.interface.ts @@ -129,6 +129,8 @@ export interface PoolStat { export interface BlockExtension { totalFees?: number; medianFee?: number; + minFee?: number; + maxFee?: number; feeRange?: number[]; reward?: number; coinbaseRaw?: string;