diff --git a/backend/src/api/mining/mining.ts b/backend/src/api/mining/mining.ts index 21ee4b35a..7e3ec525a 100644 --- a/backend/src/api/mining/mining.ts +++ b/backend/src/api/mining/mining.ts @@ -136,9 +136,13 @@ class Mining { poolsStatistics['blockCount'] = blockCount; const totalBlock24h: number = await BlocksRepository.$blockCount(null, '24h'); + const totalBlock3d: number = await BlocksRepository.$blockCount(null, '3d'); + const totalBlock1w: number = await BlocksRepository.$blockCount(null, '1w'); try { poolsStatistics['lastEstimatedHashrate'] = await bitcoinClient.getNetworkHashPs(totalBlock24h); + poolsStatistics['lastEstimatedHashrate3d'] = await bitcoinClient.getNetworkHashPs(totalBlock3d); + poolsStatistics['lastEstimatedHashrate1w'] = await bitcoinClient.getNetworkHashPs(totalBlock1w); } catch (e) { poolsStatistics['lastEstimatedHashrate'] = 0; logger.debug('Bitcoin Core is not available, using zeroed value for current hashrate', logger.tags.mining); diff --git a/frontend/src/app/components/pool-ranking/pool-ranking.component.html b/frontend/src/app/components/pool-ranking/pool-ranking.component.html index 7600797cb..f6aa4d4b9 100644 --- a/frontend/src/app/components/pool-ranking/pool-ranking.component.html +++ b/frontend/src/app/components/pool-ranking/pool-ranking.component.html @@ -90,9 +90,9 @@ Rank Pool - Hashrate + Hashrate Blocks - Avg Health Avg Block Fees Empty Blocks @@ -105,12 +105,13 @@ {{ pool.name }} - {{ pool.lastEstimatedHashrate | number: '1.2-2' }} {{ - miningStats.miningUnits.hashrateUnit }} + {{ pool.lastEstimatedHashrate | number: '1.2-2' }} {{ miningStats.miningUnits.hashrateUnit }} + {{ pool.lastEstimatedHashrate3d | number: '1.2-2' }} {{ miningStats.miningUnits.hashrateUnit }} + {{ pool.lastEstimatedHashrate1w | number: '1.2-2' }} {{ miningStats.miningUnits.hashrateUnit }} {{ pool.blockCount }} ({{ pool.share }}%) - + All miners - {{ miningStats.lastEstimatedHashrate | number: '1.2-2' }} {{ - miningStats.miningUnits.hashrateUnit }} + {{ miningStats.lastEstimatedHashrate| number: '1.2-2' }} {{ miningStats.miningUnits.hashrateUnit }} + {{ miningStats.lastEstimatedHashrate3d | number: '1.2-2' }} {{ miningStats.miningUnits.hashrateUnit }} + {{ miningStats.lastEstimatedHashrate1w | number: '1.2-2' }} {{ miningStats.miningUnits.hashrateUnit }} {{ miningStats.blockCount }} diff --git a/frontend/src/app/components/pool-ranking/pool-ranking.component.ts b/frontend/src/app/components/pool-ranking/pool-ranking.component.ts index 27a219ed3..de7f9b2e0 100644 --- a/frontend/src/app/components/pool-ranking/pool-ranking.component.ts +++ b/frontend/src/app/components/pool-ranking/pool-ranking.component.ts @@ -161,9 +161,12 @@ export class PoolRankingComponent implements OnInit { borderColor: '#000', formatter: () => { const i = pool.blockCount.toString(); - if (this.miningWindowPreference === '24h') { + if (['24h', '3d', '1w'].includes(this.miningWindowPreference)) { + let hashrate = pool.lastEstimatedHashrate; + if ('3d' === this.miningWindowPreference) { hashrate = pool.lastEstimatedHashrate3d; } + if ('1w' === this.miningWindowPreference) { hashrate = pool.lastEstimatedHashrate1w; } return `${pool.name} (${pool.share}%)
` + - pool.lastEstimatedHashrate.toFixed(2) + ' ' + miningStats.miningUnits.hashrateUnit + + hashrate.toFixed(2) + ' ' + miningStats.miningUnits.hashrateUnit + `
` + $localize`${ i }:INTERPOLATION: blocks`; } else { return `${pool.name} (${pool.share}%)
` + @@ -200,13 +203,10 @@ export class PoolRankingComponent implements OnInit { borderColor: '#000', formatter: () => { const i = totalBlockOther.toString(); - if (this.miningWindowPreference === '24h') { - return `` + $localize`Other (${percentage})` + `
` + - totalEstimatedHashrateOther.toString() + ' ' + miningStats.miningUnits.hashrateUnit + - `
` + $localize`${ i }:INTERPOLATION: blocks`; + if (['24h', '3d', '1w'].includes(this.miningWindowPreference)) { + return `` + $localize`Other (${percentage})` + `
` + totalEstimatedHashrateOther.toFixed(2) + ' ' + miningStats.miningUnits.hashrateUnit + `
` + $localize`${ i }:INTERPOLATION: blocks`; } else { - return `` + $localize`Other (${percentage})` + `
` + - $localize`${ i }:INTERPOLATION: blocks`; + return `` + $localize`Other (${percentage})` + `
` + $localize`${ i }:INTERPOLATION: blocks`; } } }, @@ -292,6 +292,8 @@ export class PoolRankingComponent implements OnInit { getEmptyMiningStat(): MiningStats { return { lastEstimatedHashrate: 0, + lastEstimatedHashrate3d: 0, + lastEstimatedHashrate1w: 0, blockCount: 0, totalEmptyBlock: 0, totalEmptyBlockRatio: '', diff --git a/frontend/src/app/interfaces/node-api.interface.ts b/frontend/src/app/interfaces/node-api.interface.ts index 0091262e1..b39f8e0d3 100644 --- a/frontend/src/app/interfaces/node-api.interface.ts +++ b/frontend/src/app/interfaces/node-api.interface.ts @@ -143,6 +143,8 @@ export interface SinglePoolStats { rank: number; share: number; lastEstimatedHashrate: number; + lastEstimatedHashrate3d: number; + lastEstimatedHashrate1w: number; emptyBlockRatio: string; logo: string; slug: string; @@ -152,6 +154,8 @@ export interface SinglePoolStats { export interface PoolsStats { blockCount: number; lastEstimatedHashrate: number; + lastEstimatedHashrate3d: number; + lastEstimatedHashrate1w: number; pools: SinglePoolStats[]; } diff --git a/frontend/src/app/services/mining.service.ts b/frontend/src/app/services/mining.service.ts index 87e9374ea..760ce93cb 100644 --- a/frontend/src/app/services/mining.service.ts +++ b/frontend/src/app/services/mining.service.ts @@ -13,6 +13,8 @@ export interface MiningUnits { export interface MiningStats { lastEstimatedHashrate: number; + lastEstimatedHashrate3d: number; + lastEstimatedHashrate1w: number; blockCount: number; totalEmptyBlock: number; totalEmptyBlockRatio: string; @@ -129,6 +131,8 @@ export class MiningService { return { share: parseFloat((poolStat.blockCount / stats.blockCount * 100).toFixed(2)), lastEstimatedHashrate: poolStat.blockCount / stats.blockCount * stats.lastEstimatedHashrate / hashrateDivider, + lastEstimatedHashrate3d: poolStat.blockCount / stats.blockCount * stats.lastEstimatedHashrate3d / hashrateDivider, + lastEstimatedHashrate1w: poolStat.blockCount / stats.blockCount * stats.lastEstimatedHashrate1w / hashrateDivider, emptyBlockRatio: (poolStat.emptyBlocks / poolStat.blockCount * 100).toFixed(2), logo: `/resources/mining-pools/` + poolStat.slug + '.svg', ...poolStat @@ -137,6 +141,8 @@ export class MiningService { return { lastEstimatedHashrate: stats.lastEstimatedHashrate / hashrateDivider, + lastEstimatedHashrate3d: stats.lastEstimatedHashrate3d / hashrateDivider, + lastEstimatedHashrate1w: stats.lastEstimatedHashrate1w / hashrateDivider, blockCount: stats.blockCount, totalEmptyBlock: totalEmptyBlock, totalEmptyBlockRatio: totalEmptyBlockRatio,