diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index d6d37b5c4..f0c04455b 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -171,7 +171,7 @@ class Blocks { } /** - * Index all blocks metadata for the mining dashboard + * [INDEXING] Index all blocks metadata for the mining dashboard */ public async $generateBlockDatabase() { if (this.blockIndexingStarted) { diff --git a/backend/src/api/mining.ts b/backend/src/api/mining.ts index a8a8af967..18d82669f 100644 --- a/backend/src/api/mining.ts +++ b/backend/src/api/mining.ts @@ -75,28 +75,7 @@ class Mining { } /** - * Return the historical difficulty adjustments and oldest indexed block timestamp - */ - public async $getHistoricalDifficulty(interval: string | null): Promise { - return await BlocksRepository.$getBlocksDifficulty(interval); - } - - /** - * Return the historical hashrates and oldest indexed block timestamp - */ - public async $getNetworkHistoricalHashrates(interval: string | null): Promise { - return await HashratesRepository.$getNetworkDailyHashrate(interval); - } - - /** - * Return the historical hashrates and oldest indexed block timestamp for one or all pools - */ - public async $getPoolsHistoricalHashrates(interval: string | null, poolId: number): Promise { - return await HashratesRepository.$getPoolsWeeklyHashrate(interval); - } - - /** - * Generate weekly mining pool hashrate history + * [INDEXING] Generate weekly mining pool hashrate history */ public async $generatePoolHashrateHistory(): Promise { if (!blocks.blockIndexingCompleted || this.weeklyHashrateIndexingStarted) { @@ -192,7 +171,7 @@ class Mining { } /** - * Generate daily hashrate data + * [INDEXING] Generate daily hashrate data */ public async $generateNetworkHashrateHistory(): Promise { if (!blocks.blockIndexingCompleted || this.hashrateIndexingStarted) { diff --git a/backend/src/routes.ts b/backend/src/routes.ts index dea9da2f2..6b1a365b6 100644 --- a/backend/src/routes.ts +++ b/backend/src/routes.ts @@ -24,6 +24,7 @@ import miningStats from './api/mining'; import axios from 'axios'; import mining from './api/mining'; import BlocksRepository from './repositories/BlocksRepository'; +import HashratesRepository from './repositories/HashratesRepository'; class Routes { constructor() {} @@ -576,7 +577,7 @@ class Routes { public async $getHistoricalDifficulty(req: Request, res: Response) { try { - const stats = await mining.$getHistoricalDifficulty(req.params.interval ?? null); + const stats = await BlocksRepository.$getBlocksDifficulty(req.params.interval ?? null); res.header('Pragma', 'public'); res.header('Cache-control', 'public'); res.setHeader('Expires', new Date(Date.now() + 1000 * 300).toUTCString()); @@ -588,7 +589,7 @@ class Routes { public async $getPoolsHistoricalHashrate(req: Request, res: Response) { try { - const hashrates = await mining.$getPoolsHistoricalHashrates(req.params.interval ?? null, parseInt(req.params.poolId, 10)); + const hashrates = await HashratesRepository.$getPoolsWeeklyHashrate(req.params.interval ?? null); const oldestIndexedBlockTimestamp = await BlocksRepository.$oldestBlockTimestamp(); res.header('Pragma', 'public'); res.header('Cache-control', 'public'); @@ -604,8 +605,8 @@ class Routes { public async $getHistoricalHashrate(req: Request, res: Response) { try { - const hashrates = await mining.$getNetworkHistoricalHashrates(req.params.interval ?? null); - const difficulty = await mining.$getHistoricalDifficulty(req.params.interval ?? null); + const hashrates = await HashratesRepository.$getNetworkDailyHashrate(req.params.interval ?? null); + const difficulty = await BlocksRepository.$getBlocksDifficulty(req.params.interval ?? null); const oldestIndexedBlockTimestamp = await BlocksRepository.$oldestBlockTimestamp(); res.header('Pragma', 'public'); res.header('Cache-control', 'public');