mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
cherry pick hashrate fix from pqsql branch (#102)
This commit is contained in:
@@ -390,7 +390,7 @@ export class StratumV1Client {
|
|||||||
//50Th/s
|
//50Th/s
|
||||||
this.noFee = false;
|
this.noFee = false;
|
||||||
if (this.entity) {
|
if (this.entity) {
|
||||||
this.hashRate = await this.clientStatisticsService.getHashRateForSession(this.clientAuthorization.address, this.clientAuthorization.worker, this.extraNonceAndSessionId);
|
this.hashRate = this.statistics.hashRate;
|
||||||
this.noFee = this.hashRate != 0 && this.hashRate < 50000000000000;
|
this.noFee = this.hashRate != 0 && this.hashRate < 50000000000000;
|
||||||
}
|
}
|
||||||
if (this.noFee || devFeeAddress == null || devFeeAddress.length < 1) {
|
if (this.noFee || devFeeAddress == null || devFeeAddress.length < 1) {
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ export class StratumV1ClientStatistics {
|
|||||||
|
|
||||||
private currentTimeSlot: number = null;
|
private currentTimeSlot: number = null;
|
||||||
private lastSave: number = null;
|
private lastSave: number = null;
|
||||||
|
|
||||||
|
public hashRate = 0;
|
||||||
|
|
||||||
|
private previousTimeSlotTime: Date;
|
||||||
|
private currentTimeSlotTime: Date;
|
||||||
|
|
||||||
|
private previousShares: number = 0;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly clientStatisticsService: ClientStatisticsService
|
private readonly clientStatisticsService: ClientStatisticsService
|
||||||
@@ -42,6 +49,8 @@ export class StratumV1ClientStatistics {
|
|||||||
|
|
||||||
if (this.currentTimeSlot == null) {
|
if (this.currentTimeSlot == null) {
|
||||||
// First record, insert it
|
// First record, insert it
|
||||||
|
this.previousTimeSlotTime = new Date();
|
||||||
|
this.currentTimeSlotTime = new Date();
|
||||||
this.currentTimeSlot = timeSlot;
|
this.currentTimeSlot = timeSlot;
|
||||||
this.shares += targetDifficulty;
|
this.shares += targetDifficulty;
|
||||||
this.acceptedCount++;
|
this.acceptedCount++;
|
||||||
@@ -65,6 +74,9 @@ export class StratumV1ClientStatistics {
|
|||||||
clientName: client.clientName,
|
clientName: client.clientName,
|
||||||
sessionId: client.sessionId
|
sessionId: client.sessionId
|
||||||
});
|
});
|
||||||
|
this.previousShares = this.shares;
|
||||||
|
this.previousTimeSlotTime = this.currentTimeSlotTime;
|
||||||
|
this.currentTimeSlotTime = new Date();
|
||||||
// Set the new time slot and add incoming shares then insert it
|
// Set the new time slot and add incoming shares then insert it
|
||||||
this.currentTimeSlot = timeSlot;
|
this.currentTimeSlot = timeSlot;
|
||||||
this.shares = targetDifficulty;
|
this.shares = targetDifficulty;
|
||||||
@@ -96,6 +108,10 @@ export class StratumV1ClientStatistics {
|
|||||||
// saving to memory for storing later
|
// saving to memory for storing later
|
||||||
this.shares += targetDifficulty;
|
this.shares += targetDifficulty;
|
||||||
this.acceptedCount++;
|
this.acceptedCount++;
|
||||||
|
if(this.shares > 0) {
|
||||||
|
const time = new Date().getTime() - this.previousTimeSlotTime.getTime();
|
||||||
|
this.hashRate = ((this.previousShares + this.shares) * 4294967296) / (time / 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user