Index weekly mining pool hashrate only if there are blocks mined

This commit is contained in:
nymkappa 2022-07-09 22:34:18 +02:00
parent 067ee168dd
commit 07cb4a49bc
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
2 changed files with 19 additions and 18 deletions

View File

@ -223,6 +223,7 @@ class Mining {
let pools = await PoolsRepository.$getPoolsInfoBetween(fromTimestamp / 1000, toTimestamp / 1000);
const totalBlocks = pools.reduce((acc, pool) => acc + pool.blockCount, 0);
if (totalBlocks > 0) {
pools = pools.map((pool: any) => {
pool.hashrate = (pool.blockCount / totalBlocks) * lastBlockHashrate;
pool.share = (pool.blockCount / totalBlocks);
@ -242,6 +243,7 @@ class Mining {
newlyIndexed += hashrates.length;
await HashratesRepository.$saveHashrates(hashrates);
hashrates.length = 0;
}
const elapsedSeconds = Math.max(1, Math.round((new Date().getTime() / 1000) - timer));
if (elapsedSeconds > 1) {

View File

@ -1,6 +1,5 @@
import { escape } from 'mysql2';
import { Common } from '../api/common';
import config from '../config';
import DB from '../database';
import logger from '../logger';
import PoolsRepository from './PoolsRepository';