Harden accounting and stratum production settings

This commit is contained in:
Ben
2026-06-08 13:27:24 -04:00
parent deaf3e56bd
commit 8252111c32
27 changed files with 414 additions and 183 deletions
@@ -1,7 +1,6 @@
import { Injectable } from '@nestjs/common';
import { InjectDataSource } from '@nestjs/typeorm';
import { DataSource } from 'typeorm';
import { timeAsync } from '../../utils/timing.utils';
const HASHES_PER_DIFFICULTY = 4294967296;
const CHART_BUCKET_SECONDS = 600;
@@ -32,14 +31,14 @@ export class ClientStatisticsService {
}
public async getHashRateForGroup(address: string, clientName: string) {
const result = await timeAsync('client statistics group hashrate query', () => this.dataSource.query(`
const result = await this.dataSource.query(`
SELECT
COALESCE((SUM("creditedDifficulty") * ${HASHES_PER_DIFFICULTY}) / ${CHART_BUCKET_SECONDS}, 0) AS "hashRate"
FROM "accepted_share_entity"
WHERE "address" = $1
AND "clientName" = $2
AND "acceptedAt" > NOW() - INTERVAL '1 hour'
`, [address, clientName]), { address, clientName });
`, [address, clientName]);
return parseFloat(result[0]?.hashRate ?? '0');
}
@@ -91,12 +90,7 @@ export class ClientStatisticsService {
ORDER BY "label"
`;
const result = await timeAsync('client statistics chart query', () => this.dataSource.query(query, params), {
filterSql,
params: params.length,
limit,
windowSql,
});
const result = await this.dataSource.query(query, params);
return result.map(res => {
return {