diff --git a/backend/src/api/mining.ts b/backend/src/api/mining.ts index 8d11abfa7..7e7008351 100644 --- a/backend/src/api/mining.ts +++ b/backend/src/api/mining.ts @@ -89,7 +89,6 @@ class Mining { }); poolsStatistics['pools'] = poolsStats; - poolsStatistics['oldestIndexedBlockTimestamp'] = await BlocksRepository.$oldestBlockTimestamp(); const blockCount: number = await BlocksRepository.$blockCount(null, interval); poolsStatistics['blockCount'] = blockCount; diff --git a/backend/src/routes.ts b/backend/src/routes.ts index fa298cc22..ef8dd47e5 100644 --- a/backend/src/routes.ts +++ b/backend/src/routes.ts @@ -669,14 +669,12 @@ class Routes { public async $getHistoricalBlockFeeRates(req: Request, res: Response) { try { const blockFeeRates = await mining.$getHistoricalBlockFeeRates(req.params.interval); - const oldestIndexedBlockTimestamp = await BlocksRepository.$oldestBlockTimestamp(); + const blockCount = await BlocksRepository.$blockCount(null, null); res.header('Pragma', 'public'); res.header('Cache-control', 'public'); + res.header('X-total-count', blockCount.toString()); res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString()); - res.json({ - oldestIndexedBlockTimestamp: oldestIndexedBlockTimestamp, - blockFeeRates: blockFeeRates, - }); + res.json(blockFeeRates); } catch (e) { res.status(500).send(e instanceof Error ? e.message : e); } diff --git a/frontend/src/app/components/block-fee-rates-graph/block-fee-rates-graph.component.html b/frontend/src/app/components/block-fee-rates-graph/block-fee-rates-graph.component.html index ec3773ca8..016c80936 100644 --- a/frontend/src/app/components/block-fee-rates-graph/block-fee-rates-graph.component.html +++ b/frontend/src/app/components/block-fee-rates-graph/block-fee-rates-graph.component.html @@ -8,34 +8,34 @@
-
diff --git a/frontend/src/app/components/block-fee-rates-graph/block-fee-rates-graph.component.ts b/frontend/src/app/components/block-fee-rates-graph/block-fee-rates-graph.component.ts index 2cd421f26..3a4d2b89d 100644 --- a/frontend/src/app/components/block-fee-rates-graph/block-fee-rates-graph.component.ts +++ b/frontend/src/app/components/block-fee-rates-graph/block-fee-rates-graph.component.ts @@ -76,7 +76,7 @@ export class BlockFeeRatesGraphComponent implements OnInit { this.isLoading = true; return this.apiService.getHistoricalBlockFeeRates$(timespan) .pipe( - tap((data: any) => { + tap((response) => { // Group by percentile const seriesData = { 'Min': [], @@ -87,7 +87,7 @@ export class BlockFeeRatesGraphComponent implements OnInit { '90th': [], 'Max': [] }; - for (const rate of data.blockFeeRates) { + for (const rate of response.body) { const timestamp = rate.timestamp * 1000; seriesData['Min'].push([timestamp, rate.avgFee_0, rate.avgHeight]); seriesData['10th'].push([timestamp, rate.avgFee_10, rate.avgHeight]); @@ -130,13 +130,9 @@ export class BlockFeeRatesGraphComponent implements OnInit { }); this.isLoading = false; }), - map((data: any) => { - const availableTimespanDay = ( - (new Date().getTime() / 1000) - (data.oldestIndexedBlockTimestamp) - ) / 3600 / 24; - + map((response) => { return { - availableTimespanDay: availableTimespanDay, + blockCount: parseInt(response.headers.get('x-total-count'), 10), }; }), ); diff --git a/frontend/src/app/components/difficulty-adjustments-table/difficulty-adjustments-table.components.ts b/frontend/src/app/components/difficulty-adjustments-table/difficulty-adjustments-table.components.ts index 854c1c349..fb7d5c8f7 100644 --- a/frontend/src/app/components/difficulty-adjustments-table/difficulty-adjustments-table.components.ts +++ b/frontend/src/app/components/difficulty-adjustments-table/difficulty-adjustments-table.components.ts @@ -34,10 +34,6 @@ export class DifficultyAdjustmentsTable implements OnInit { .pipe( map((response) => { const data = response.body; - const availableTimespanDay = ( - (new Date().getTime() / 1000) - (data.oldestIndexedBlockTimestamp) - ) / 3600 / 24; - const tableData = []; for (let i = data.difficulty.length - 1; i > 0; --i) { const selectedPowerOfTen: any = selectPowerOfTen(data.difficulty[i].difficulty); @@ -53,7 +49,6 @@ export class DifficultyAdjustmentsTable implements OnInit { this.isLoading = false; return { - availableTimespanDay: availableTimespanDay, difficulty: tableData.slice(0, 6), }; }), diff --git a/frontend/src/app/docs/api-docs/api-docs-data.ts b/frontend/src/app/docs/api-docs/api-docs-data.ts index fcb60a154..20108d250 100644 --- a/frontend/src/app/docs/api-docs/api-docs-data.ts +++ b/frontend/src/app/docs/api-docs/api-docs-data.ts @@ -3049,7 +3049,6 @@ export const restApiDocsData = [ "slug": "antpool" }, ... - "oldestIndexedBlockTimestamp": 1231006505, "blockCount": 1005, "lastEstimatedHashrate": 230086716765559200000 }` @@ -3080,7 +3079,6 @@ export const restApiDocsData = [ }, ... ], - "oldestIndexedBlockTimestamp": 1296688602, "blockCount": 2226180, "lastEstimatedHashrate": 602244182177430.8 }` @@ -4025,111 +4023,103 @@ export const restApiDocsData = [ esModule: [], commonJS: [], curl: [`1m`], - response: `{ - "oldestIndexedBlockTimestamp": 1571434851, - "blockFeeRates": [ - { - "avgHeight": 732152, - "timestamp": 1650132959, - "avgFee_0": 1, - "avgFee_10": 2, - "avgFee_25": 2, - "avgFee_50": 3, - "avgFee_75": 4, - "avgFee_90": 8, - "avgFee_100": 393 - }, - { - "avgHeight": 732158, - "timestamp": 1650134432, - "avgFee_0": 1, - "avgFee_10": 1, - "avgFee_25": 2, - "avgFee_50": 4, - "avgFee_75": 6, - "avgFee_90": 10, - "avgFee_100": 240 - }, - { - "avgHeight": 732161, - "timestamp": 1650135818, - "avgFee_0": 1, - "avgFee_10": 1, - "avgFee_25": 1, - "avgFee_50": 2, - "avgFee_75": 5, - "avgFee_90": 8, - "avgFee_100": 251 - }, - ... - ] -}` + response: `[ + { + "avgHeight": 732152, + "timestamp": 1650132959, + "avgFee_0": 1, + "avgFee_10": 2, + "avgFee_25": 2, + "avgFee_50": 3, + "avgFee_75": 4, + "avgFee_90": 8, + "avgFee_100": 393 + }, + { + "avgHeight": 732158, + "timestamp": 1650134432, + "avgFee_0": 1, + "avgFee_10": 1, + "avgFee_25": 2, + "avgFee_50": 4, + "avgFee_75": 6, + "avgFee_90": 10, + "avgFee_100": 240 + }, + { + "avgHeight": 732161, + "timestamp": 1650135818, + "avgFee_0": 1, + "avgFee_10": 1, + "avgFee_25": 1, + "avgFee_50": 2, + "avgFee_75": 5, + "avgFee_90": 8, + "avgFee_100": 251 + }, + ... +]` }, codeSampleTestnet: { esModule: [], commonJS: [], curl: [`1m`], - response: `{ - "oldestIndexedBlockTimestamp": 1296688602, - "blockFeeRates": [ - { - "avgHeight": 2196306, - "timestamp": 1650360168, - "avgFee_0": 1, - "avgFee_10": 1, - "avgFee_25": 1, - "avgFee_50": 1, - "avgFee_75": 2, - "avgFee_90": 28, - "avgFee_100": 2644 - }, - { - "avgHeight": 2196308, - "timestamp": 1650361209, - "avgFee_0": 1, - "avgFee_10": 1, - "avgFee_25": 1, - "avgFee_50": 4, - "avgFee_75": 12, - "avgFee_90": 65, - "avgFee_100": 102 - }, - ... - ] -}` + response: `[ + { + "avgHeight": 2196306, + "timestamp": 1650360168, + "avgFee_0": 1, + "avgFee_10": 1, + "avgFee_25": 1, + "avgFee_50": 1, + "avgFee_75": 2, + "avgFee_90": 28, + "avgFee_100": 2644 + }, + { + "avgHeight": 2196308, + "timestamp": 1650361209, + "avgFee_0": 1, + "avgFee_10": 1, + "avgFee_25": 1, + "avgFee_50": 4, + "avgFee_75": 12, + "avgFee_90": 65, + "avgFee_100": 102 + }, + ... +]` }, codeSampleSignet: { esModule: [], commonJS: [], curl: [`1m`], response: `{ - "oldestIndexedBlockTimestamp": 1598918400, - "blockFeeRates": [ - { - "avgHeight": 86620, - "timestamp": 1650360010, - "avgFee_0": 1, - "avgFee_10": 1, - "avgFee_25": 1, - "avgFee_50": 1, - "avgFee_75": 1, - "avgFee_90": 1, - "avgFee_100": 1 - }, - { - "avgHeight": 86623, - "timestamp": 1650361330, - "avgFee_0": 1, - "avgFee_10": 1, - "avgFee_25": 1, - "avgFee_50": 1, - "avgFee_75": 1, - "avgFee_90": 1, - "avgFee_100": 1 - }, - ... - ] -}` +"blockFeeRates": [ + { + "avgHeight": 86620, + "timestamp": 1650360010, + "avgFee_0": 1, + "avgFee_10": 1, + "avgFee_25": 1, + "avgFee_50": 1, + "avgFee_75": 1, + "avgFee_90": 1, + "avgFee_100": 1 + }, + { + "avgHeight": 86623, + "timestamp": 1650361330, + "avgFee_0": 1, + "avgFee_10": 1, + "avgFee_25": 1, + "avgFee_50": 1, + "avgFee_75": 1, + "avgFee_90": 1, + "avgFee_100": 1 + }, + ... +]` }, codeSampleLiquid: emptyCodeSample, codeSampleLiquidTestnet: emptyCodeSample, diff --git a/frontend/src/app/interfaces/node-api.interface.ts b/frontend/src/app/interfaces/node-api.interface.ts index 4998a0d70..d1f9932d7 100644 --- a/frontend/src/app/interfaces/node-api.interface.ts +++ b/frontend/src/app/interfaces/node-api.interface.ts @@ -76,7 +76,6 @@ export interface SinglePoolStats { export interface PoolsStats { blockCount: number; lastEstimatedHashrate: number; - oldestIndexedBlockTimestamp: number; pools: SinglePoolStats[]; } diff --git a/frontend/src/app/services/api.service.ts b/frontend/src/app/services/api.service.ts index 7a523a7b3..134877f72 100644 --- a/frontend/src/app/services/api.service.ts +++ b/frontend/src/app/services/api.service.ts @@ -189,7 +189,7 @@ export class ApiService { getHistoricalBlockFeeRates$(interval: string | undefined) : Observable { return this.httpClient.get( this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/blocks/fee-rates` + - (interval !== undefined ? `/${interval}` : '') + (interval !== undefined ? `/${interval}` : ''), { observe: 'response' } ); }