This commit is contained in:
Ben Wilson
2023-07-20 11:57:14 -04:00
parent afb5ead74b
commit 81da017b94
3 changed files with 9 additions and 4 deletions
+2 -1
View File
@@ -372,7 +372,7 @@ export class StratumV1Client extends EasyUnsubscribe {
const { submissionDifficulty, submissionHash } = this.calculateDifficulty(header);
console.log(`DIFF: ${submissionDifficulty} of ${this.sessionDifficulty} from ${this.clientAuthorization.worker + '.' + this.extraNonceAndSessionId}`);
//console.log(`Header: ${header.toString('hex')}`);
if (submissionDifficulty >= this.sessionDifficulty) {
@@ -413,6 +413,7 @@ export class StratumV1Client extends EasyUnsubscribe {
eStratumErrorCode.LowDifficultyShare,
'Difficulty too low').response();
console.error(err);
console.log(`Header: ${header.toString('hex')}`);
await this.promiseSocket.write(err);
return false;
}
+5 -1
View File
@@ -3,6 +3,7 @@ import { ClientEntity } from '../ORM/client/client.entity';
const CACHE_SIZE = 30;
const TARGET_SUBMISSION_PER_SECOND = 10;
const MIN_DIFF = 1e-9;
export class StratumV1ClientStatistics {
private submissionCacheStart: Date;
@@ -65,10 +66,13 @@ export class StratumV1ClientStatistics {
}
private nearestPowerOfTwo(val) {
private nearestPowerOfTwo(val): number {
if (val === 0) {
return null;
}
if (val < MIN_DIFF) {
return MIN_DIFF;
}
let x = val | (val >> 1);
x = x | (x >> 2);
x = x | (x >> 4);