hashrate is a number not a string

This commit is contained in:
Mononaut 2024-05-30 21:24:33 +00:00
parent 833418514e
commit e11ce14f81
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E
4 changed files with 10 additions and 10 deletions

View File

@ -78,17 +78,17 @@ export class ActiveAccelerationBox implements OnChanges {
if (!pool) { if (!pool) {
continue; continue;
} }
totalAcceleratedHashrate += parseFloat(pool.lastEstimatedHashrate); totalAcceleratedHashrate += pool.lastEstimatedHashrate;
} }
this.acceleratedByPercentage = ((totalAcceleratedHashrate / parseFloat(this.miningStats.lastEstimatedHashrate)) * 100).toFixed(1) + '%'; this.acceleratedByPercentage = ((totalAcceleratedHashrate / this.miningStats.lastEstimatedHashrate) * 100).toFixed(1) + '%';
data.push(getDataItem( data.push(getDataItem(
totalAcceleratedHashrate, totalAcceleratedHashrate,
'var(--mainnet-alt)', 'var(--mainnet-alt)',
`${this.acceleratedByPercentage} accelerating`, `${this.acceleratedByPercentage} accelerating`,
) as PieSeriesOption); ) as PieSeriesOption);
const notAcceleratedByPercentage = ((1 - (totalAcceleratedHashrate / parseFloat(this.miningStats.lastEstimatedHashrate))) * 100).toFixed(1) + '%'; const notAcceleratedByPercentage = ((1 - (totalAcceleratedHashrate / this.miningStats.lastEstimatedHashrate)) * 100).toFixed(1) + '%';
data.push(getDataItem( data.push(getDataItem(
(parseFloat(this.miningStats.lastEstimatedHashrate) - totalAcceleratedHashrate), (this.miningStats.lastEstimatedHashrate - totalAcceleratedHashrate),
'rgba(127, 127, 127, 0.3)', 'rgba(127, 127, 127, 0.3)',
`${notAcceleratedByPercentage} not accelerating`, `${notAcceleratedByPercentage} not accelerating`,
) as PieSeriesOption); ) as PieSeriesOption);

View File

@ -163,7 +163,7 @@ export class PoolRankingComponent implements OnInit {
const i = pool.blockCount.toString(); const i = pool.blockCount.toString();
if (this.miningWindowPreference === '24h') { if (this.miningWindowPreference === '24h') {
return `<b style="color: white">${pool.name} (${pool.share}%)</b><br>` + return `<b style="color: white">${pool.name} (${pool.share}%)</b><br>` +
pool.lastEstimatedHashrate.toString() + ' ' + miningStats.miningUnits.hashrateUnit + pool.lastEstimatedHashrate.toFixed(2) + ' ' + miningStats.miningUnits.hashrateUnit +
`<br>` + $localize`${ i }:INTERPOLATION: blocks`; `<br>` + $localize`${ i }:INTERPOLATION: blocks`;
} else { } else {
return `<b style="color: white">${pool.name} (${pool.share}%)</b><br>` + return `<b style="color: white">${pool.name} (${pool.share}%)</b><br>` +
@ -291,7 +291,7 @@ export class PoolRankingComponent implements OnInit {
*/ */
getEmptyMiningStat(): MiningStats { getEmptyMiningStat(): MiningStats {
return { return {
lastEstimatedHashrate: 'Error', lastEstimatedHashrate: 0,
blockCount: 0, blockCount: 0,
totalEmptyBlock: 0, totalEmptyBlock: 0,
totalEmptyBlockRatio: '', totalEmptyBlockRatio: '',

View File

@ -140,7 +140,7 @@ export interface SinglePoolStats {
emptyBlocks: number; emptyBlocks: number;
rank: number; rank: number;
share: number; share: number;
lastEstimatedHashrate: string; lastEstimatedHashrate: number;
emptyBlockRatio: string; emptyBlockRatio: string;
logo: string; logo: string;
slug: string; slug: string;

View File

@ -12,7 +12,7 @@ export interface MiningUnits {
} }
export interface MiningStats { export interface MiningStats {
lastEstimatedHashrate: string; lastEstimatedHashrate: number;
blockCount: number; blockCount: number;
totalEmptyBlock: number; totalEmptyBlock: number;
totalEmptyBlockRatio: string; totalEmptyBlockRatio: string;
@ -111,7 +111,7 @@ export class MiningService {
const poolsStats = stats.pools.map((poolStat) => { const poolsStats = stats.pools.map((poolStat) => {
return { return {
share: parseFloat((poolStat.blockCount / stats.blockCount * 100).toFixed(2)), share: parseFloat((poolStat.blockCount / stats.blockCount * 100).toFixed(2)),
lastEstimatedHashrate: (poolStat.blockCount / stats.blockCount * stats.lastEstimatedHashrate / hashrateDivider).toFixed(2), lastEstimatedHashrate: poolStat.blockCount / stats.blockCount * stats.lastEstimatedHashrate / hashrateDivider,
emptyBlockRatio: (poolStat.emptyBlocks / poolStat.blockCount * 100).toFixed(2), emptyBlockRatio: (poolStat.emptyBlocks / poolStat.blockCount * 100).toFixed(2),
logo: `/resources/mining-pools/` + poolStat.slug + '.svg', logo: `/resources/mining-pools/` + poolStat.slug + '.svg',
...poolStat ...poolStat
@ -119,7 +119,7 @@ export class MiningService {
}); });
return { return {
lastEstimatedHashrate: (stats.lastEstimatedHashrate / hashrateDivider).toFixed(2), lastEstimatedHashrate: stats.lastEstimatedHashrate / hashrateDivider,
blockCount: stats.blockCount, blockCount: stats.blockCount,
totalEmptyBlock: totalEmptyBlock, totalEmptyBlock: totalEmptyBlock,
totalEmptyBlockRatio: totalEmptyBlockRatio, totalEmptyBlockRatio: totalEmptyBlockRatio,