From 057b5bd2e16e4607f52151b5af62719451f62947 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Wed, 20 Apr 2022 13:12:32 +0900 Subject: [PATCH 1/8] Update block API to use indexing if available --- backend/src/api/blocks.ts | 68 ++++++++++++++----- backend/src/api/common.ts | 2 +- backend/src/repositories/BlocksRepository.ts | 31 ++++++++- backend/src/routes.ts | 6 +- backend/src/utils/blocks-utils.ts | 8 ++- .../app/components/block/block.component.html | 13 +++- .../app/components/block/block.component.ts | 8 +-- 7 files changed, 102 insertions(+), 34 deletions(-) diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index 6af631382..a723f8069 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -134,26 +134,25 @@ class Blocks { blockExtended.extras.avgFeeRate = stats.avgfeerate; } - if (Common.indexingEnabled()) { - let pool: PoolTag; - if (blockExtended.extras?.coinbaseTx !== undefined) { - pool = await this.$findBlockMiner(blockExtended.extras?.coinbaseTx); - } else { - pool = await poolsRepository.$getUnknownPool(); - } - - if (!pool) { // We should never have this situation in practise - logger.warn(`Cannot assign pool to block ${blockExtended.height} and 'unknown' pool does not exist. Check your "pools" table entries`); - return blockExtended; - } - - blockExtended.extras.pool = { - id: pool.id, - name: pool.name, - slug: pool.slug, - }; + let pool: PoolTag; + if (blockExtended.extras?.coinbaseTx !== undefined) { + pool = await this.$findBlockMiner(blockExtended.extras?.coinbaseTx); + } else { + pool = await poolsRepository.$getUnknownPool(); } + if (!pool) { // We should never have this situation in practise + logger.warn(`Cannot assign pool to block ${blockExtended.height} and 'unknown' pool does not exist. ` + + `Check your "pools" table entries`); + return blockExtended; + } + + blockExtended.extras.pool = { + id: pool.id, + name: pool.name, + slug: pool.slug, + }; + return blockExtended; } @@ -389,6 +388,39 @@ class Blocks { return prepareBlock(blockExtended); } + /** + * Index a block by hash if it's missing from the database. Returns the block after indexing + */ + public async $getBlock(hash: string): Promise { + // Block has already been indexed + if (Common.indexingEnabled()) { + const dbBlock = await blocksRepository.$getBlockByHash(hash); + if (dbBlock != null) { + logger.info('GET BLOCK: already indexed'); + return prepareBlock(dbBlock); + } + } + + const block = await bitcoinApi.$getBlock(hash); + + // Not Bitcoin network, return the block as it + if (['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) === false) { + logger.info('GET BLOCK: using bitcoin backend'); + return block; + } + + // Bitcoin network, add our custom data on top + logger.info('GET BLOCK: index block on the fly'); + const transactions = await this.$getTransactionsExtended(hash, block.height, true); + const blockExtended = await this.$getBlockExtended(block, transactions); + if (Common.indexingEnabled()) { + delete(blockExtended['coinbaseTx']); + await blocksRepository.$saveBlockInDatabase(blockExtended); + } + + return blockExtended; + } + public async $getBlocksExtras(fromHeight?: number, limit: number = 15): Promise { // Note - This API is breaking if indexing is not available. For now it is okay because we only // use it for the mining pages, and mining pages should not be available if indexing is turned off. diff --git a/backend/src/api/common.ts b/backend/src/api/common.ts index 45ef5f576..bebc6c58b 100644 --- a/backend/src/api/common.ts +++ b/backend/src/api/common.ts @@ -174,7 +174,7 @@ export class Common { return ( ['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) && config.DATABASE.ENABLED === true && - config.MEMPOOL.INDEXING_BLOCKS_AMOUNT != 0 + config.MEMPOOL.INDEXING_BLOCKS_AMOUNT !== 0 ); } } diff --git a/backend/src/repositories/BlocksRepository.ts b/backend/src/repositories/BlocksRepository.ts index 0792f130f..b1980c26c 100644 --- a/backend/src/repositories/BlocksRepository.ts +++ b/backend/src/repositories/BlocksRepository.ts @@ -287,6 +287,7 @@ class BlocksRepository { return null; } + rows[0].fee_span = JSON.parse(rows[0].fee_span); return rows[0]; } catch (e) { logger.err(`Cannot get indexed block ${height}. Reason: ` + (e instanceof Error ? e.message : e)); @@ -294,6 +295,34 @@ class BlocksRepository { } } + /** + * Get one block by hash + */ + public async $getBlockByHash(hash: string): Promise { + try { + const query = ` + SELECT *, UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp, hash as id, + pools.id as pool_id, pools.name as pool_name, pools.link as pool_link, pools.slug as pool_slug, + pools.addresses as pool_addresses, pools.regexes as pool_regexes, + previous_block_hash as previousblockhash + FROM blocks + JOIN pools ON blocks.pool_id = pools.id + WHERE hash = '${hash}'; + `; + const [rows]: any[] = await DB.query(query); + + if (rows.length <= 0) { + return null; + } + + rows[0].fee_span = JSON.parse(rows[0].fee_span); + return rows[0]; + } catch (e) { + logger.err(`Cannot get indexed block ${hash}. Reason: ` + (e instanceof Error ? e.message : e)); + throw e; + } + } + /** * Return blocks difficulty */ @@ -457,7 +486,7 @@ class BlocksRepository { /** * Get the historical averaged block rewards */ - public async $getHistoricalBlockRewards(div: number, interval: string | null): Promise { + public async $getHistoricalBlockRewards(div: number, interval: string | null): Promise { try { let query = `SELECT CAST(AVG(height) as INT) as avg_height, diff --git a/backend/src/routes.ts b/backend/src/routes.ts index 72bf3b483..52f590775 100644 --- a/backend/src/routes.ts +++ b/backend/src/routes.ts @@ -702,8 +702,8 @@ class Routes { public async getBlock(req: Request, res: Response) { try { - const result = await bitcoinApi.$getBlock(req.params.hash); - res.json(result); + const block = await blocks.$getBlock(req.params.hash); + res.json(block); } catch (e) { res.status(500).send(e instanceof Error ? e.message : e); } @@ -727,7 +727,7 @@ class Routes { res.status(500).send(e instanceof Error ? e.message : e); } } - + public async getBlocks(req: Request, res: Response) { try { loadingIndicators.setProgress('blocks', 0); diff --git a/backend/src/utils/blocks-utils.ts b/backend/src/utils/blocks-utils.ts index 7b5c0b23a..8760a08c0 100644 --- a/backend/src/utils/blocks-utils.ts +++ b/backend/src/utils/blocks-utils.ts @@ -1,4 +1,4 @@ -import { BlockExtended } from "../mempool.interfaces"; +import { BlockExtended } from '../mempool.interfaces'; export function prepareBlock(block: any): BlockExtended { return { @@ -17,9 +17,11 @@ export function prepareBlock(block: any): BlockExtended { extras: { coinbaseRaw: block.coinbase_raw ?? block.extras.coinbaseRaw, medianFee: block.medianFee ?? block.median_fee ?? block.extras?.medianFee, - feeRange: block.feeRange ?? block.fee_range ?? block?.extras?.feeSpan, + feeRange: block.feeRange ?? block.fee_span, reward: block.reward ?? block?.extras?.reward, - totalFees: block.totalFees ?? block?.fees ?? block?.extras.totalFees, + totalFees: block.totalFees ?? block?.fees ?? block?.extras?.totalFees, + avgFee: block?.extras?.avgFee ?? block.avg_fee, + avgFeeRate: block?.avgFeeRate ?? block.avg_fee_rate, pool: block?.extras?.pool ?? (block?.pool_id ? { id: block.pool_id, name: block.pool_name, diff --git a/frontend/src/app/components/block/block.component.html b/frontend/src/app/components/block/block.component.html index 8b511b30c..9dea439c3 100644 --- a/frontend/src/app/components/block/block.component.html +++ b/frontend/src/app/components/block/block.component.html @@ -105,7 +105,18 @@ Miner - + + + {{ block.extras.pool.name }} + + + + + {{ block.extras.pool.name }} + + diff --git a/frontend/src/app/components/block/block.component.ts b/frontend/src/app/components/block/block.component.ts index 512b6b411..c69245786 100644 --- a/frontend/src/app/components/block/block.component.ts +++ b/frontend/src/app/components/block/block.component.ts @@ -31,7 +31,6 @@ export class BlockComponent implements OnInit, OnDestroy { blockSubsidy: number; fees: number; paginationMaxSize: number; - coinbaseTx: Transaction; page = 1; itemsPerPage: number; txsLoadingStatus$: Observable; @@ -50,7 +49,7 @@ export class BlockComponent implements OnInit, OnDestroy { private location: Location, private router: Router, private electrsApiService: ElectrsApiService, - private stateService: StateService, + public stateService: StateService, private seoService: SeoService, private websocketService: WebsocketService, private relativeUrlPipe: RelativeUrlPipe, @@ -88,7 +87,6 @@ export class BlockComponent implements OnInit, OnDestroy { const blockHash: string = params.get('id') || ''; this.block = undefined; this.page = 1; - this.coinbaseTx = undefined; this.error = undefined; this.fees = undefined; this.stateService.markBlock$.next({}); @@ -145,7 +143,6 @@ 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?.extras?.coinbaseTx; this.setBlockSubsidy(); if (block?.extras?.reward !== undefined) { this.fees = block.extras.reward / 100000000 - this.blockSubsidy; @@ -167,9 +164,6 @@ export class BlockComponent implements OnInit, OnDestroy { if (this.fees === undefined && transactions[0]) { this.fees = transactions[0].vout.reduce((acc: number, curr: Vout) => acc + curr.value, 0) / 100000000 - this.blockSubsidy; } - if (!this.coinbaseTx && transactions[0]) { - this.coinbaseTx = transactions[0]; - } this.transactions = transactions; this.isLoadingTransactions = false; }, From 067d160f33a3303faba313dbf24f13f7b75cd1eb Mon Sep 17 00:00:00 2001 From: nymkappa Date: Wed, 20 Apr 2022 13:30:06 +0900 Subject: [PATCH 2/8] Use block.extras on bitcoin network for fees/subsidy --- .../app/components/block/block.component.html | 17 ++++++++++++++--- .../src/app/components/block/block.component.ts | 9 +++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/components/block/block.component.html b/frontend/src/app/components/block/block.component.html index 9dea439c3..569abdec2 100644 --- a/frontend/src/app/components/block/block.component.html +++ b/frontend/src/app/components/block/block.component.html @@ -81,15 +81,26 @@ Total fees - + + + + + + -   + +   + Subsidy + fees: - + + + + diff --git a/frontend/src/app/components/block/block.component.ts b/frontend/src/app/components/block/block.component.ts index c69245786..2fa6ec75d 100644 --- a/frontend/src/app/components/block/block.component.ts +++ b/frontend/src/app/components/block/block.component.ts @@ -206,13 +206,10 @@ export class BlockComponent implements OnInit, OnDestroy { this.queryParamsSubscription.unsubscribe(); } + // TODO - Refactor this.fees/this.reward for liquid because it is not + // used anymore on Bitcoin networks (we use block.extras directly) setBlockSubsidy() { - if (this.network === 'liquid' || this.network === 'liquidtestnet') { - this.blockSubsidy = 0; - return; - } - const halvings = Math.floor(this.block.height / 210000); - this.blockSubsidy = 50 * 2 ** -halvings; + this.blockSubsidy = 0; } pageChange(page: number, target: HTMLElement) { From ff74e6ea8caca1a8f35bc25c6d01982cacf0ab0e Mon Sep 17 00:00:00 2001 From: nymkappa Date: Wed, 20 Apr 2022 13:40:10 +0900 Subject: [PATCH 3/8] If block exists in memory cache, return it directly for /block API --- backend/src/api/blocks.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index a723f8069..9d2e91c78 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -392,6 +392,12 @@ class Blocks { * Index a block by hash if it's missing from the database. Returns the block after indexing */ public async $getBlock(hash: string): Promise { + // Check the memory cache + const blockByHash = this.getBlocks().find((b) => b.id === hash); + if (blockByHash) { + return blockByHash; + } + // Block has already been indexed if (Common.indexingEnabled()) { const dbBlock = await blocksRepository.$getBlockByHash(hash); From 964bf2671ef53ed7a47f6848921e0517db8a3595 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Wed, 20 Apr 2022 13:43:46 +0900 Subject: [PATCH 4/8] Delete MinerComponent --- frontend/src/app/app.module.ts | 2 - .../app/components/miner/miner.component.html | 12 --- .../app/components/miner/miner.component.scss | 3 - .../app/components/miner/miner.component.ts | 94 ------------------- 4 files changed, 111 deletions(-) delete mode 100644 frontend/src/app/components/miner/miner.component.html delete mode 100644 frontend/src/app/components/miner/miner.component.scss delete mode 100644 frontend/src/app/components/miner/miner.component.ts diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 336cfead2..c9cd63c0c 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -40,7 +40,6 @@ import { AssetComponent } from './components/asset/asset.component'; import { AssetsComponent } from './components/assets/assets.component'; import { AssetsNavComponent } from './components/assets/assets-nav/assets-nav.component'; import { StatusViewComponent } from './components/status-view/status-view.component'; -import { MinerComponent } from './components/miner/miner.component'; import { SharedModule } from './shared/shared.module'; import { NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap'; import { FeesBoxComponent } from './components/fees-box/fees-box.component'; @@ -108,7 +107,6 @@ import { BlockSizesWeightsGraphComponent } from './components/block-sizes-weight LbtcPegsGraphComponent, AssetComponent, AssetsComponent, - MinerComponent, StatusViewComponent, FeesBoxComponent, DashboardComponent, diff --git a/frontend/src/app/components/miner/miner.component.html b/frontend/src/app/components/miner/miner.component.html deleted file mode 100644 index f4798d07d..000000000 --- a/frontend/src/app/components/miner/miner.component.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - {{ miner }} - - - Unknown - - diff --git a/frontend/src/app/components/miner/miner.component.scss b/frontend/src/app/components/miner/miner.component.scss deleted file mode 100644 index b6e8c8ca1..000000000 --- a/frontend/src/app/components/miner/miner.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.badge { - font-size: 14px; -} diff --git a/frontend/src/app/components/miner/miner.component.ts b/frontend/src/app/components/miner/miner.component.ts deleted file mode 100644 index 733204120..000000000 --- a/frontend/src/app/components/miner/miner.component.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { Component, Input, OnChanges, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; -import { AssetsService } from 'src/app/services/assets.service'; -import { Transaction } from 'src/app/interfaces/electrs.interface'; -import { StateService } from 'src/app/services/state.service'; -import { RelativeUrlPipe } from 'src/app/shared/pipes/relative-url/relative-url.pipe'; - -@Component({ - selector: 'app-miner', - templateUrl: './miner.component.html', - styleUrls: ['./miner.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class MinerComponent implements OnChanges { - @Input() coinbaseTransaction: Transaction; - miner = ''; - title = ''; - url = ''; - target = '_blank'; - loading = true; - - constructor( - private assetsService: AssetsService, - private cd: ChangeDetectorRef, - public stateService: StateService, - private relativeUrlPipe: RelativeUrlPipe, - ) { } - - ngOnChanges() { - this.miner = ''; - if (this.stateService.env.MINING_DASHBOARD) { - this.miner = 'Unknown'; - this.url = this.relativeUrlPipe.transform(`/mining/pool/unknown`); - this.target = ''; - } - this.loading = true; - this.findMinerFromCoinbase(); - } - - findMinerFromCoinbase() { - if (this.coinbaseTransaction == null || this.coinbaseTransaction.vin == null || this.coinbaseTransaction.vin.length === 0) { - return null; - } - - this.assetsService.getMiningPools$.subscribe((pools) => { - for (const vout of this.coinbaseTransaction.vout) { - if (!vout.scriptpubkey_address) { - continue; - } - - if (pools.payout_addresses[vout.scriptpubkey_address]) { - this.miner = pools.payout_addresses[vout.scriptpubkey_address].name; - this.title = $localize`:@@miner-identified-by-payout:Identified by payout address: '${vout.scriptpubkey_address}:PAYOUT_ADDRESS:'`; - const pool = pools.payout_addresses[vout.scriptpubkey_address]; - if (this.stateService.env.MINING_DASHBOARD && pools.slugs && pools.slugs[pool.name] !== undefined) { - this.url = this.relativeUrlPipe.transform(`/mining/pool/${pools.slugs[pool.name]}`); - this.target = ''; - } else { - this.url = pool.link; - } - break; - } - - for (const tag in pools.coinbase_tags) { - if (pools.coinbase_tags.hasOwnProperty(tag)) { - const coinbaseAscii = this.hex2ascii(this.coinbaseTransaction.vin[0].scriptsig); - if (coinbaseAscii.indexOf(tag) > -1) { - const pool = pools.coinbase_tags[tag]; - this.miner = pool.name; - this.title = $localize`:@@miner-identified-by-coinbase:Identified by coinbase tag: '${tag}:TAG:'`; - if (this.stateService.env.MINING_DASHBOARD && pools.slugs && pools.slugs[pool.name] !== undefined) { - this.url = this.relativeUrlPipe.transform(`/mining/pool/${pools.slugs[pool.name]}`); - this.target = ''; - } else { - this.url = pool.link; - } - break; - } - } - } - } - - this.loading = false; - this.cd.markForCheck(); - }); - } - - hex2ascii(hex: string) { - let str = ''; - for (let i = 0; i < hex.length; i += 2) { - str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); - } - return str; - } -} From 384c8d17cf367630c1dca45756f21f9892f30437 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Mon, 25 Apr 2022 15:50:26 +0900 Subject: [PATCH 5/8] Only process mining pools on Bitcoin networks --- backend/src/api/blocks.ts | 34 ++++++++++--------- backend/src/api/common.ts | 4 +-- .../app/components/block/block.component.html | 2 +- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index 9d2e91c78..1f27d8c0e 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -134,24 +134,26 @@ class Blocks { blockExtended.extras.avgFeeRate = stats.avgfeerate; } - let pool: PoolTag; - if (blockExtended.extras?.coinbaseTx !== undefined) { - pool = await this.$findBlockMiner(blockExtended.extras?.coinbaseTx); - } else { - pool = await poolsRepository.$getUnknownPool(); - } + if (['mainnet', 'testnet', 'signet', 'regtest'].includes(config.MEMPOOL.NETWORK)) { + let pool: PoolTag; + if (blockExtended.extras?.coinbaseTx !== undefined) { + pool = await this.$findBlockMiner(blockExtended.extras?.coinbaseTx); + } else { + pool = await poolsRepository.$getUnknownPool(); + } - if (!pool) { // We should never have this situation in practise - logger.warn(`Cannot assign pool to block ${blockExtended.height} and 'unknown' pool does not exist. ` + - `Check your "pools" table entries`); - return blockExtended; - } + if (!pool) { // We should never have this situation in practise + logger.warn(`Cannot assign pool to block ${blockExtended.height} and 'unknown' pool does not exist. ` + + `Check your "pools" table entries`); + return blockExtended; + } - blockExtended.extras.pool = { - id: pool.id, - name: pool.name, - slug: pool.slug, - }; + blockExtended.extras.pool = { + id: pool.id, + name: pool.name, + slug: pool.slug, + }; + } return blockExtended; } diff --git a/backend/src/api/common.ts b/backend/src/api/common.ts index bebc6c58b..d4b57f204 100644 --- a/backend/src/api/common.ts +++ b/backend/src/api/common.ts @@ -169,10 +169,10 @@ export class Common { default: return null; } } - + static indexingEnabled(): boolean { return ( - ['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) && + ['mainnet', 'testnet', 'signet', 'regtest'].includes(config.MEMPOOL.NETWORK) && config.DATABASE.ENABLED === true && config.MEMPOOL.INDEXING_BLOCKS_AMOUNT !== 0 ); diff --git a/frontend/src/app/components/block/block.component.html b/frontend/src/app/components/block/block.component.html index 569abdec2..87e45e088 100644 --- a/frontend/src/app/components/block/block.component.html +++ b/frontend/src/app/components/block/block.component.html @@ -122,7 +122,7 @@ {{ block.extras.pool.name }} - + {{ block.extras.pool.name }} From 6ae44c6f7e68aecd3ecb6d8ac12eba5def201983 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Wed, 27 Apr 2022 17:43:32 +0900 Subject: [PATCH 6/8] Call node backend block API instead of electrs --- frontend/src/app/components/block/block.component.ts | 6 ++++-- frontend/src/app/services/api.service.ts | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/components/block/block.component.ts b/frontend/src/app/components/block/block.component.ts index 2fa6ec75d..57417a5c3 100644 --- a/frontend/src/app/components/block/block.component.ts +++ b/frontend/src/app/components/block/block.component.ts @@ -10,6 +10,7 @@ import { SeoService } from 'src/app/services/seo.service'; import { WebsocketService } from 'src/app/services/websocket.service'; import { RelativeUrlPipe } from 'src/app/shared/pipes/relative-url/relative-url.pipe'; import { BlockExtended } from 'src/app/interfaces/node-api.interface'; +import { ApiService } from 'src/app/services/api.service'; @Component({ selector: 'app-block', @@ -53,6 +54,7 @@ export class BlockComponent implements OnInit, OnDestroy { private seoService: SeoService, private websocketService: WebsocketService, private relativeUrlPipe: RelativeUrlPipe, + private apiService: ApiService ) { } ngOnInit() { @@ -122,7 +124,7 @@ export class BlockComponent implements OnInit, OnDestroy { this.location.replaceState( this.router.createUrlTree([(this.network ? '/' + this.network : '') + '/block/', hash]).toString() ); - return this.electrsApiService.getBlock$(hash); + return this.apiService.getBlock$(hash); }) ); } @@ -132,7 +134,7 @@ export class BlockComponent implements OnInit, OnDestroy { return of(blockInCache); } - return this.electrsApiService.getBlock$(blockHash); + return this.apiService.getBlock$(blockHash); } }), tap((block: BlockExtended) => { diff --git a/frontend/src/app/services/api.service.ts b/frontend/src/app/services/api.service.ts index 982461ad1..9b096394a 100644 --- a/frontend/src/app/services/api.service.ts +++ b/frontend/src/app/services/api.service.ts @@ -154,6 +154,10 @@ export class ApiService { ); } + getBlock$(hash: string): Observable { + return this.httpClient.get(this.apiBaseUrl + this.apiBasePath + '/api/v1/block/' + hash); + } + getHistoricalHashrate$(interval: string | undefined): Observable { return this.httpClient.get( this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/hashrate` + From d26b1436b5ef7b3eba6a9ee792f79dabf2ec2f12 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Wed, 27 Apr 2022 21:47:14 +0900 Subject: [PATCH 7/8] Always expose /block/{hash} API in the node backend --- backend/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index 8560064a9..f2658a22a 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -350,7 +350,8 @@ class Server { this.app .get(config.MEMPOOL.API_URL_PREFIX + 'blocks-extras', routes.getBlocksExtras) - .get(config.MEMPOOL.API_URL_PREFIX + 'blocks-extras/:height', routes.getBlocksExtras); + .get(config.MEMPOOL.API_URL_PREFIX + 'blocks-extras/:height', routes.getBlocksExtras) + .get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash', routes.getBlock); if (config.MEMPOOL.BACKEND !== 'esplora') { this.app @@ -362,7 +363,6 @@ class Server { .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/hex', routes.getRawTransaction) .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/status', routes.getTransactionStatus) .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/outspends', routes.getTransactionOutspends) - .get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash', routes.getBlock) .get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash/header', routes.getBlockHeader) .get(config.MEMPOOL.API_URL_PREFIX + 'blocks', routes.getBlocks) .get(config.MEMPOOL.API_URL_PREFIX + 'blocks/:height', routes.getBlocks) From 433bddab1f011ec144e226ea29cebf4116ee84e7 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Tue, 10 May 2022 15:54:11 +0200 Subject: [PATCH 8/8] Remove unused pools.json observable definition --- frontend/src/app/services/assets.service.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/src/app/services/assets.service.ts b/frontend/src/app/services/assets.service.ts index 9454ef7e2..880883a8c 100644 --- a/frontend/src/app/services/assets.service.ts +++ b/frontend/src/app/services/assets.service.ts @@ -14,7 +14,6 @@ export class AssetsService { getAssetsJson$: Observable<{ array: AssetExtended[]; objects: any}>; getAssetsMinimalJson$: Observable; - getMiningPools$: Observable; constructor( private httpClient: HttpClient, @@ -66,6 +65,5 @@ export class AssetsService { }), shareReplay(1), ); - this.getMiningPools$ = this.httpClient.get(apiBaseUrl + '/resources/pools.json').pipe(shareReplay(1)); } }