Skip to content

Commit 694c447

Browse files
committed
Improve "pool hashrate" and "miner hashrate", they are double like they are supposed to be in the database
1 parent ac64fac commit 694c447

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

src/Miningcore/Api/Responses/GetPoolStatsResponse.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ namespace Miningcore.Api.Responses;
22

33
public partial class AggregatedPoolStats
44
{
5-
public float PoolHashrate { get; set; }
5+
public double PoolHashrate { get; set; }
66
public int ConnectedMiners { get; set; }
7-
public int ValidSharesPerSecond { get; set; }
7+
public double ValidSharesPerSecond { get; set; }
88
public double NetworkHashrate { get; set; }
99
public double NetworkDifficulty { get; set; }
1010

src/Miningcore/Mining/PoolStats.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ public class PoolStats
44
{
55
public DateTime? LastPoolBlockTime { get; set; }
66
public int ConnectedMiners { get; set; }
7-
public ulong PoolHashrate { get; set; }
8-
public int SharesPerSecond { get; set; }
7+
public double PoolHashrate { get; set; }
8+
public double SharesPerSecond { get; set; }
99
}

src/Miningcore/Mining/StatsRecorder.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,11 @@ private async Task UpdatePoolHashratesAsync(CancellationToken ct)
130130
// pool hashrate
131131
var poolHashesAccumulated = result.Sum(x => x.Sum);
132132
var poolHashrate = pool.HashrateFromShares(poolHashesAccumulated, poolHashTimeFrame);
133-
poolHashrate = Math.Floor(poolHashrate);
134-
pool.PoolStats.PoolHashrate = (ulong) poolHashrate;
133+
pool.PoolStats.PoolHashrate = poolHashrate;
135134

136135
// pool shares
137136
var poolHashesCountAccumulated = result.Sum(x => x.Count);
138-
pool.PoolStats.SharesPerSecond = (int) (poolHashesCountAccumulated / poolHashTimeFrame);
137+
pool.PoolStats.SharesPerSecond = Math.Round(poolHashesCountAccumulated / poolHashTimeFrame, 3);
139138

140139
messageBus.NotifyHashrateUpdated(pool.Config.Id, poolHashrate);
141140
}

src/Miningcore/Persistence/Model/PoolStats.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ public record PoolStats
66
public string PoolId { get; init; }
77

88
public int ConnectedMiners { get; init; }
9-
public float PoolHashrate { get; init; }
9+
public double PoolHashrate { get; init; }
1010
public double NetworkHashrate { get; init; }
1111
public double NetworkDifficulty { get; init; }
1212
public DateTime? LastNetworkBlockTime { get; init; }
1313
public long BlockHeight { get; init; }
1414
public int ConnectedPeers { get; init; }
15-
public int SharesPerSecond { get; init; }
15+
public double SharesPerSecond { get; init; }
1616

1717
public DateTime Created { get; init; }
1818
}

src/Miningcore/Persistence/Postgres/Entities/PoolStats.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ public class PoolStats
66
public string PoolId { get; set; }
77

88
public int ConnectedMiners { get; set; }
9-
public float PoolHashrate { get; set; }
9+
public double PoolHashrate { get; set; }
1010
public double NetworkHashrate { get; set; }
1111
public double NetworkDifficulty { get; set; }
1212
public DateTime? LastNetworkBlockTime { get; set; }
1313
public long BlockHeight { get; set; }
1414
public int ConnectedPeers { get; set; }
15-
public int SharesPerSecond { get; set; }
15+
public double SharesPerSecond { get; set; }
1616

1717
public DateTime Created { get; set; }
1818
}

0 commit comments

Comments
 (0)