diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index dfa5caf46..fae1d453b 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -681,9 +681,12 @@ class Blocks { logger.info(`Re-indexed 10 blocks and summaries. Also re-indexed the last difficulty adjustments. Will re-index latest hashrates in a few seconds.`, logger.tags.mining); indexer.reindex(); } - await blocksRepository.$saveBlockInDatabase(blockExtended); - this.updateTimerProgress(timer, `saved ${this.currentBlockHeight} to database`); + } + await blocksRepository.$saveBlockInDatabase(blockExtended); + this.updateTimerProgress(timer, `saved ${this.currentBlockHeight} to database`); + + if (!fastForwarded) { const lastestPriceId = await PricesRepository.$getLatestPriceId(); this.updateTimerProgress(timer, `got latest price id ${this.currentBlockHeight}`); if (priceUpdater.historyInserted === true && lastestPriceId !== null) { diff --git a/frontend/src/app/components/block/block.component.html b/frontend/src/app/components/block/block.component.html index b5bb7d5d3..1a0a81026 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 - {{ block.extras.feeRange[1] | number:'1.0-0' }} - {{ block.extras.feeRange[block.extras.feeRange.length - 1] | 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 be0e1318c..17e6e9b7f 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; @@ -668,4 +672,23 @@ export class BlockComponent implements OnInit, OnDestroy { } } } + + getMinBlockFee(block: BlockExtended): number { + if (block?.extras?.feeRange) { + // heuristic to check if feeRange is adjusted for effective rates + if (block.extras.medianFee === block.extras.feeRange[3]) { + return block.extras.feeRange[1]; + } else { + return block.extras.feeRange[0]; + } + } + return 0; + } + + getMaxBlockFee(block: BlockExtended): number { + if (block?.extras?.feeRange) { + return block.extras.feeRange[block.extras.feeRange.length - 1]; + } + return 0; + } } \ No newline at end of file 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 69f13b6fe..0c22cf391 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 @@
- {{ block?.extras?.feeRange?.[0] | number:feeRounding }} - {{ - block?.extras?.feeRange[block?.extras?.feeRange?.length - 1] | 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 87cffd228..5242c1fe5 100644 --- a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts +++ b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts @@ -114,6 +114,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); @@ -240,6 +243,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, @@ -278,6 +285,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); } @@ -366,4 +375,23 @@ export class BlockchainBlocksComponent implements OnInit, OnChanges, OnDestroy { } return emptyBlocks; } + + getMinBlockFee(block: BlockExtended): number { + if (block?.extras?.feeRange) { + // heuristic to check if feeRange is adjusted for effective rates + if (block.extras.medianFee === block.extras.feeRange[3]) { + return block.extras.feeRange[1]; + } else { + return block.extras.feeRange[0]; + } + } + return 0; + } + + getMaxBlockFee(block: BlockExtended): number { + if (block?.extras?.feeRange) { + return block.extras.feeRange[block.extras.feeRange.length - 1]; + } + return 0; + } } diff --git a/frontend/src/app/interfaces/node-api.interface.ts b/frontend/src/app/interfaces/node-api.interface.ts index 2e58c79e4..2f9b95ab1 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;