mirror of
https://github.com/mempool/mempool.git
synced 2024-11-20 18:32:19 +01:00
Remove useless mining function wrapper in backend
This commit is contained in:
parent
8532d13a0d
commit
1ced44d970
@ -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) {
|
||||
|
@ -75,28 +75,7 @@ class Mining {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the historical difficulty adjustments and oldest indexed block timestamp
|
||||
*/
|
||||
public async $getHistoricalDifficulty(interval: string | null): Promise<object> {
|
||||
return await BlocksRepository.$getBlocksDifficulty(interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the historical hashrates and oldest indexed block timestamp
|
||||
*/
|
||||
public async $getNetworkHistoricalHashrates(interval: string | null): Promise<object> {
|
||||
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<object> {
|
||||
return await HashratesRepository.$getPoolsWeeklyHashrate(interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate weekly mining pool hashrate history
|
||||
* [INDEXING] Generate weekly mining pool hashrate history
|
||||
*/
|
||||
public async $generatePoolHashrateHistory(): Promise<void> {
|
||||
if (!blocks.blockIndexingCompleted || this.weeklyHashrateIndexingStarted) {
|
||||
@ -192,7 +171,7 @@ class Mining {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate daily hashrate data
|
||||
* [INDEXING] Generate daily hashrate data
|
||||
*/
|
||||
public async $generateNetworkHashrateHistory(): Promise<void> {
|
||||
if (!blocks.blockIndexingCompleted || this.hashrateIndexingStarted) {
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user