mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
updated at, hashrate calculation
This commit is contained in:
committed by
Benjamin Wilson
parent
0c34f23284
commit
522ef126d9
@@ -25,7 +25,8 @@ export class ClientStatisticsService {
|
|||||||
shares: clientStatistic.shares,
|
shares: clientStatistic.shares,
|
||||||
acceptedCount: clientStatistic.acceptedCount,
|
acceptedCount: clientStatistic.acceptedCount,
|
||||||
updatedAt: new Date()
|
updatedAt: new Date()
|
||||||
})
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
public async insert(clientStatistic: Partial<ClientStatisticsEntity>) {
|
public async insert(clientStatistic: Partial<ClientStatisticsEntity>) {
|
||||||
await this.clientStatisticsRepository.insert(clientStatistic);
|
await this.clientStatisticsRepository.insert(clientStatistic);
|
||||||
@@ -151,14 +152,16 @@ export class ClientStatisticsService {
|
|||||||
|
|
||||||
if (result.length < 2) {
|
if (result.length < 2) {
|
||||||
const time = new Date(latestStat.updatedAt).getTime() - new Date(latestStat.createdAt).getTime();
|
const time = new Date(latestStat.updatedAt).getTime() - new Date(latestStat.createdAt).getTime();
|
||||||
if (time < 1) {
|
// 1min
|
||||||
|
if (time < 1000 * 60) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (parseFloat(latestStat.shares) * 4294967296) / (time / 1000);
|
return (parseFloat(latestStat.shares) * 4294967296) / (time / 1000);
|
||||||
} else {
|
} else {
|
||||||
const secondLatestStat = result[1];
|
const secondLatestStat = result[1];
|
||||||
const time = new Date(latestStat.updatedAt).getTime() - new Date(secondLatestStat.createdAt).getTime();
|
const time = new Date(latestStat.updatedAt).getTime() - new Date(secondLatestStat.createdAt).getTime();
|
||||||
if (time < 1) {
|
// 1min
|
||||||
|
if (time < 1000 * 60) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return ((parseFloat(latestStat.shares) + parseFloat(secondLatestStat.shares)) * 4294967296) / (time / 1000);
|
return ((parseFloat(latestStat.shares) + parseFloat(secondLatestStat.shares)) * 4294967296) / (time / 1000);
|
||||||
|
|||||||
Reference in New Issue
Block a user