From 456bd5a18e688e3773b806522779c2d414793a15 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Fri, 4 Feb 2022 19:28:00 +0900 Subject: [PATCH] Renamed `extra` to `extras` --- backend/src/api/blocks.ts | 14 +++++++------- backend/src/api/websocket-handler.ts | 4 ++-- backend/src/mempool.interfaces.ts | 2 +- backend/src/repositories/BlocksRepository.ts | 2 +- .../src/app/components/block/block.component.html | 4 ++-- .../src/app/components/block/block.component.ts | 10 +++++----- .../blockchain-blocks.component.html | 4 ++-- .../blockchain-blocks.component.ts | 12 ++++++------ .../mempool-blocks/mempool-blocks.component.ts | 2 +- .../tx-fee-rating/tx-fee-rating.component.ts | 6 +++--- frontend/src/app/interfaces/node-api.interface.ts | 2 +- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index 081442567..cd72d91e0 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -97,7 +97,7 @@ class Blocks { private getBlockExtended(block: IEsploraApi.Block, transactions: TransactionExtended[]): BlockExtended { const blockExtended: BlockExtended = Object.assign({}, block); - blockExtended.extra = { + blockExtended.extras = { reward: transactions[0].vout.reduce((acc, curr) => acc + curr.value, 0), coinbaseTx: transactionUtils.stripCoinbaseTransaction(transactions[0]), }; @@ -106,9 +106,9 @@ class Blocks { transactionsTmp.shift(); transactionsTmp.sort((a, b) => b.effectiveFeePerVsize - a.effectiveFeePerVsize); - blockExtended.extra.medianFee = transactionsTmp.length > 0 ? + blockExtended.extras.medianFee = transactionsTmp.length > 0 ? Common.median(transactionsTmp.map((tx) => tx.effectiveFeePerVsize)) : 0; - blockExtended.extra.feeRange = transactionsTmp.length > 0 ? + blockExtended.extras.feeRange = transactionsTmp.length > 0 ? Common.getFeesInRange(transactionsTmp, 8) : [0, 0]; return blockExtended; @@ -205,8 +205,8 @@ class Blocks { const blockExtended = this.getBlockExtended(block, transactions); let miner: PoolTag; - if (blockExtended?.extra?.coinbaseTx) { - miner = await this.$findBlockMiner(blockExtended.extra.coinbaseTx); + if (blockExtended?.extras?.coinbaseTx) { + miner = await this.$findBlockMiner(blockExtended.extras.coinbaseTx); } else { miner = await poolsRepository.$getUnknownPool(); } @@ -276,8 +276,8 @@ class Blocks { if (['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) === true) { let miner: PoolTag; - if (blockExtended?.extra?.coinbaseTx) { - miner = await this.$findBlockMiner(blockExtended.extra.coinbaseTx); + if (blockExtended?.extras?.coinbaseTx) { + miner = await this.$findBlockMiner(blockExtended.extras.coinbaseTx); } else { miner = await poolsRepository.$getUnknownPool(); } diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index 5478445df..53d74925d 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -380,8 +380,8 @@ class WebsocketHandler { mBlocks = mempoolBlocks.getMempoolBlocks(); } - if (block.extra) { - block.extra.matchRate = matchRate; + if (block.extras) { + block.extras.matchRate = matchRate; } this.wss.clients.forEach((client) => { diff --git a/backend/src/mempool.interfaces.ts b/backend/src/mempool.interfaces.ts index 17509b814..7dfcd3956 100644 --- a/backend/src/mempool.interfaces.ts +++ b/backend/src/mempool.interfaces.ts @@ -86,7 +86,7 @@ export interface BlockExtension { } export interface BlockExtended extends IEsploraApi.Block { - extra?: BlockExtension; + extras?: BlockExtension; } export interface TransactionMinerInfo { diff --git a/backend/src/repositories/BlocksRepository.ts b/backend/src/repositories/BlocksRepository.ts index 2d55fc1cb..fd9549845 100644 --- a/backend/src/repositories/BlocksRepository.ts +++ b/backend/src/repositories/BlocksRepository.ts @@ -42,7 +42,7 @@ class BlocksRepository { poolTag.id, 0, '[]', - block.extra ? block.extra.medianFee : 0, + block.extras ? block.extras.medianFee : 0, ]; await connection.query(query, params); diff --git a/frontend/src/app/components/block/block.component.html b/frontend/src/app/components/block/block.component.html index 4f6e1cc03..8970bd372 100644 --- a/frontend/src/app/components/block/block.component.html +++ b/frontend/src/app/components/block/block.component.html @@ -74,9 +74,9 @@
- + - + diff --git a/frontend/src/app/components/block/block.component.ts b/frontend/src/app/components/block/block.component.ts index c079b5efd..4e7b08373 100644 --- a/frontend/src/app/components/block/block.component.ts +++ b/frontend/src/app/components/block/block.component.ts @@ -77,8 +77,8 @@ export class BlockComponent implements OnInit, OnDestroy { if (block.id === this.blockHash) { this.block = block; - if (block?.extra?.reward != undefined) { - this.fees = block.extra.reward / 100000000 - this.blockSubsidy; + if (block?.extras?.reward != undefined) { + this.fees = block.extras.reward / 100000000 - this.blockSubsidy; } } }); @@ -145,10 +145,10 @@ export class BlockComponent implements OnInit, OnDestroy { this.seoService.setTitle($localize`:@@block.component.browser-title:Block ${block.height}:BLOCK_HEIGHT:: ${block.id}:BLOCK_ID:`); this.isLoadingBlock = false; - this.coinbaseTx = block?.extra?.coinbaseTx; + this.coinbaseTx = block?.extras?.coinbaseTx; this.setBlockSubsidy(); - if (block?.extra?.reward !== undefined) { - this.fees = block.extra.reward / 100000000 - this.blockSubsidy; + if (block?.extras?.reward !== undefined) { + this.fees = block.extras.reward / 100000000 - this.blockSubsidy; } this.stateService.markBlock$.next({ blockHeight: this.blockHeight }); this.isLoadingTransactions = true; 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 4a74dab3c..50fd82b09 100644 --- a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html +++ b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html @@ -8,10 +8,10 @@
- ~{{ block?.extra?.medianFee | number:feeRounding }} sat/vB + ~{{ block?.extras?.medianFee | number:feeRounding }} sat/vB
- {{ block?.extra?.feeRange[1] | number:feeRounding }} - {{ block?.extra?.feeRange[block?.extra?.feeRange.length - 1] | number:feeRounding }} sat/vB + {{ block?.extras?.feeRange[1] | number:feeRounding }} - {{ block?.extras?.feeRange[block?.extras?.feeRange.length - 1] | 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 7dcec9cc3..ef076e74b 100644 --- a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts +++ b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts @@ -69,8 +69,8 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy { this.blocks.unshift(block); this.blocks = this.blocks.slice(0, this.stateService.env.KEEP_BLOCKS_AMOUNT); - if (this.blocksFilled && !this.tabHidden && block.extra) { - block.extra.stage = block.extra.matchRate >= 66 ? 1 : 2; + if (this.blocksFilled && !this.tabHidden && block.extras) { + block.extras.stage = block.extras.matchRate >= 66 ? 1 : 2; } if (txConfirmed) { @@ -151,8 +151,8 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy { const greenBackgroundHeight = 100 - (block.weight / this.stateService.env.BLOCK_WEIGHT_UNITS) * 100; let addLeft = 0; - if (block?.extra?.stage === 1) { - block.extra.stage = 2; + if (block?.extras?.stage === 1) { + block.extras.stage = 2; addLeft = -205; } @@ -170,8 +170,8 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy { getStyleForEmptyBlock(block: BlockExtended) { let addLeft = 0; - if (block?.extra?.stage === 1) { - block.extra.stage = 2; + if (block?.extras?.stage === 1) { + block.extras.stage = 2; addLeft = -205; } diff --git a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts index 1bfb665b6..de345a7d8 100644 --- a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts +++ b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts @@ -153,7 +153,7 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy { this.blockSubscription = this.stateService.blocks$ .subscribe(([block]) => { - if (block?.extra?.matchRate >= 66 && !this.tabHidden) { + if (block?.extras?.matchRate >= 66 && !this.tabHidden) { this.blockIndex++; } }); diff --git a/frontend/src/app/components/tx-fee-rating/tx-fee-rating.component.ts b/frontend/src/app/components/tx-fee-rating/tx-fee-rating.component.ts index 0a2100831..3879ca835 100644 --- a/frontend/src/app/components/tx-fee-rating/tx-fee-rating.component.ts +++ b/frontend/src/app/components/tx-fee-rating/tx-fee-rating.component.ts @@ -29,7 +29,7 @@ export class TxFeeRatingComponent implements OnInit, OnChanges, OnDestroy { ngOnInit() { this.blocksSubscription = this.stateService.blocks$.subscribe(([block]) => { this.blocks.push(block); - if (this.tx.status.confirmed && this.tx.status.block_height === block.height && block?.extra?.medianFee > 0) { + if (this.tx.status.confirmed && this.tx.status.block_height === block.height && block?.extras?.medianFee > 0) { this.calculateRatings(block); this.cd.markForCheck(); } @@ -43,7 +43,7 @@ export class TxFeeRatingComponent implements OnInit, OnChanges, OnDestroy { } const foundBlock = this.blocks.find((b) => b.height === this.tx.status.block_height); - if (foundBlock && foundBlock?.extra?.medianFee > 0) { + if (foundBlock && foundBlock?.extras?.medianFee > 0) { this.calculateRatings(foundBlock); } } @@ -54,7 +54,7 @@ export class TxFeeRatingComponent implements OnInit, OnChanges, OnDestroy { calculateRatings(block: BlockExtended) { const feePervByte = this.tx.effectiveFeePerVsize || this.tx.fee / (this.tx.weight / 4); - this.medianFeeNeeded = block?.extra?.medianFee; + this.medianFeeNeeded = block?.extras?.medianFee; // Block not filled if (block.weight < this.stateService.env.BLOCK_WEIGHT_UNITS * 0.95) { diff --git a/frontend/src/app/interfaces/node-api.interface.ts b/frontend/src/app/interfaces/node-api.interface.ts index c48b3e000..373385422 100644 --- a/frontend/src/app/interfaces/node-api.interface.ts +++ b/frontend/src/app/interfaces/node-api.interface.ts @@ -93,6 +93,6 @@ export interface BlockExtension { } export interface BlockExtended extends Block { - extra?: BlockExtension; + extras?: BlockExtension; }
Median fee~{{ block?.extra?.medianFee | number:'1.0-0' }} sat/vB ~{{ block?.extras?.medianFee | number:'1.0-0' }} sat/vB