[mining] show pools estimated hashrate on 3d and 1w timeframes

This commit is contained in:
nymkappa 2024-10-30 10:46:44 +01:00
parent 76cfa3ca47
commit a257bcc12a
No known key found for this signature in database
GPG Key ID: 92358FC85D9645DE
5 changed files with 33 additions and 15 deletions

View File

@ -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);

View File

@ -90,9 +90,9 @@
<th class="d-none d-md-table-cell" i18n="mining.rank">Rank</th>
<th class=""></th>
<th class="" i18n="mining.pool-name">Pool</th>
<th class="" *ngIf="this.miningWindowPreference === '24h'" i18n="mining.hashrate">Hashrate</th>
<th class="" *ngIf="['24h', '3d', '1w'].includes(this.miningWindowPreference)" i18n="mining.hashrate">Hashrate</th>
<th class="" i18n="master-page.blocks">Blocks</th>
<th *ngIf="auditAvailable" class="health text-right widget" [ngClass]="{'health-column': this.miningWindowPreference === '24h'}" i18n="latest-blocks.avg_health"
<th *ngIf="auditAvailable" class="health text-right widget" [ngClass]="{'health-column': ['24h', '3d', '1w'].includes(this.miningWindowPreference)}" i18n="latest-blocks.avg_health"
i18n-ngbTooltip="latest-blocks.avg_health" ngbTooltip="Avg Health" placement="bottom" #health [disableTooltip]="!isEllipsisActive(health)">Avg Health</th>
<th *ngIf="auditAvailable" class="d-none d-sm-table-cell" i18n="mining.fees-per-block">Avg Block Fees</th>
<th class="d-none d-lg-table-cell" i18n="mining.empty-blocks">Empty Blocks</th>
@ -105,12 +105,13 @@
<img width="25" height="25" src="{{ pool.logo }}" [alt]="pool.name + ' mining pool logo'" onError="this.onerror=null; this.src = '/resources/mining-pools/default.svg'">
</td>
<td class="pool-name"><a [routerLink]="[('/mining/pool/' + pool.slug) | relativeUrl]">{{ pool.name }}</a></td>
<td class="" *ngIf="this.miningWindowPreference === '24h'">{{ pool.lastEstimatedHashrate | number: '1.2-2' }} {{
miningStats.miningUnits.hashrateUnit }}</td>
<td class="" *ngIf="'24h' === this.miningWindowPreference">{{ pool.lastEstimatedHashrate | number: '1.2-2' }} {{ miningStats.miningUnits.hashrateUnit }}</td>
<td class="" *ngIf="'3d' === this.miningWindowPreference">{{ pool.lastEstimatedHashrate3d | number: '1.2-2' }} {{ miningStats.miningUnits.hashrateUnit }}</td>
<td class="" *ngIf="'1w' === this.miningWindowPreference">{{ pool.lastEstimatedHashrate1w | number: '1.2-2' }} {{ miningStats.miningUnits.hashrateUnit }}</td>
<td class="d-flex justify-content-center">
{{ pool.blockCount }}<span class="d-none d-md-table-cell">&nbsp;({{ pool.share }}%)</span>
</td>
<td *ngIf="auditAvailable" class="health text-right" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable, 'health-column': this.miningWindowPreference === '24h'}">
<td *ngIf="auditAvailable" class="health text-right" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable, 'health-column': ['24h', '3d', '1w'].includes(this.miningWindowPreference)}">
<a
class="health-badge badge"
[class.badge-success]="pool.avgMatchRate >= 99"
@ -136,8 +137,9 @@
<td class="d-none d-md-table-cell"></td>
<td class="text-right"></td>
<td class=""><b i18n="mining.all-miners">All miners</b></td>
<td class="" *ngIf="this.miningWindowPreference === '24h'"><b>{{ miningStats.lastEstimatedHashrate | number: '1.2-2' }} {{
miningStats.miningUnits.hashrateUnit }}</b></td>
<td class="" *ngIf="'24h' === this.miningWindowPreference">{{ miningStats.lastEstimatedHashrate| number: '1.2-2' }} {{ miningStats.miningUnits.hashrateUnit }}</td>
<td class="" *ngIf="'3d' === this.miningWindowPreference">{{ miningStats.lastEstimatedHashrate3d | number: '1.2-2' }} {{ miningStats.miningUnits.hashrateUnit }}</td>
<td class="" *ngIf="'1w' === this.miningWindowPreference">{{ miningStats.lastEstimatedHashrate1w | number: '1.2-2' }} {{ miningStats.miningUnits.hashrateUnit }}</td>
<td class=""><b>{{ miningStats.blockCount }}</b></td>
<td *ngIf="auditAvailable"></td>
<td *ngIf="auditAvailable"></td>

View File

@ -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 `<b style="color: white">${pool.name} (${pool.share}%)</b><br>` +
pool.lastEstimatedHashrate.toFixed(2) + ' ' + miningStats.miningUnits.hashrateUnit +
hashrate.toFixed(2) + ' ' + miningStats.miningUnits.hashrateUnit +
`<br>` + $localize`${ i }:INTERPOLATION: blocks`;
} else {
return `<b style="color: white">${pool.name} (${pool.share}%)</b><br>` +
@ -200,13 +203,10 @@ export class PoolRankingComponent implements OnInit {
borderColor: '#000',
formatter: () => {
const i = totalBlockOther.toString();
if (this.miningWindowPreference === '24h') {
return `<b style="color: white">` + $localize`Other (${percentage})` + `</b><br>` +
totalEstimatedHashrateOther.toString() + ' ' + miningStats.miningUnits.hashrateUnit +
`<br>` + $localize`${ i }:INTERPOLATION: blocks`;
if (['24h', '3d', '1w'].includes(this.miningWindowPreference)) {
return `<b style="color: white">` + $localize`Other (${percentage})` + `</b><br>` + totalEstimatedHashrateOther.toFixed(2) + ' ' + miningStats.miningUnits.hashrateUnit + `<br>` + $localize`${ i }:INTERPOLATION: blocks`;
} else {
return `<b style="color: white">` + $localize`Other (${percentage})` + `</b><br>` +
$localize`${ i }:INTERPOLATION: blocks`;
return `<b style="color: white">` + $localize`Other (${percentage})` + `</b><br>` + $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: '',

View File

@ -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[];
}

View File

@ -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,