Number of Miners reported by Pool Stats now represents number of workers instead just miners
@@ -155,11 +155,8 @@ namespace Miningcore.Mining
var poolHashrate = pool.HashrateFromShares(poolHashesAccumulated, windowActual) * HashrateBoostFactor;
// update
- pool.PoolStats.ConnectedMiners = byMiner.Length;
pool.PoolStats.PoolHashrate = (ulong) Math.Ceiling(poolHashrate);
pool.PoolStats.SharesPerSecond = (int) (poolHashesCountAccumulated / windowActual);
-
- messageBus.NotifyHashrateUpdated(pool.Config.Id, poolHashrate);
}
}
@@ -170,29 +167,9 @@ namespace Miningcore.Mining
pool.PoolStats.PoolHashrate = 0;
pool.PoolStats.SharesPerSecond = 0;
- messageBus.NotifyHashrateUpdated(pool.Config.Id, 0);
-
logger.Info(() => $"Reset performance stats for pool {poolId}");
}
- // persist
- await cf.RunTx(async (con, tx) =>
- {
- var mapped = new Persistence.Model.PoolStats
- {
- PoolId = poolId,
- Created = start
- };
-
- mapper.Map(pool.PoolStats, mapped);
- mapper.Map(pool.NetworkStats, mapped);
-
- await statsRepo.InsertPoolStatsAsync(con, tx, mapped);
- });
-
- if(result.Length == 0)
- continue;
-
// retrieve most recent miner/worker hashrate sample, if non-zero
var previousMinerWorkerHashrates = await cf.Run(async (con) =>
{
@@ -210,9 +187,12 @@ namespace Miningcore.Mining
var currentNonZeroMinerWorkers = new HashSet<string>();
// calculate & update miner, worker hashrates
+ var workerCount = 0;
+
foreach(var minerHashes in byMiner)
{
double minerTotalHashrate = 0;
+ workerCount += minerHashes.Count();
await cf.RunTx(async (con, tx) =>
{
@@ -254,6 +234,8 @@ namespace Miningcore.Mining
// identify and reset "orphaned" hashrates
var orphanedHashrateForMinerWorker = previousNonZeroMinerWorkers.Except(currentNonZeroMinerWorkers).ToArray();
+ if(orphanedHashrateForMinerWorker.Any())
+ {
await cf.RunTx(async (con, tx) =>
{
// reset
@@ -282,6 +264,27 @@ namespace Miningcore.Mining
}
});
}
+
+ // persist poolstats
+ pool.PoolStats.ConnectedMiners = workerCount;
+
+ await cf.RunTx(async (con, tx) =>
+ {
+ var mapped = new Persistence.Model.PoolStats
+ {
+ PoolId = poolId,
+ Created = start
+ };
+
+ mapper.Map(pool.PoolStats, mapped);
+ mapper.Map(pool.NetworkStats, mapped);
+
+ await statsRepo.InsertPoolStatsAsync(con, tx, mapped);
+ });
+
+ // broadcast
+ messageBus.NotifyHashrateUpdated(pool.Config.Id, pool.PoolStats.PoolHashrate);
+ }
}
private async Task PerformStatsGcAsync()
