reduce minimum diff

This commit is contained in:
Ben Wilson
2023-06-28 10:23:54 -04:00
parent e230e25e91
commit 37a65e43b2
2 changed files with 16 additions and 13 deletions
+10 -7
View File
@@ -77,7 +77,7 @@ export class StratumV1Client extends EasyUnsubscribe {
private async handleMessage(socket: Socket, message: string) { private async handleMessage(socket: Socket, message: string) {
console.log('Received:', message); //console.log('Received:', message);
// Parse the message and check if it's the initial subscription message // Parse the message and check if it's the initial subscription message
let parsedMessage = null; let parsedMessage = null;
@@ -233,6 +233,7 @@ export class StratumV1Client extends EasyUnsubscribe {
let clearJobs = false; let clearJobs = false;
if (lastIntervalCount === interValCount) { if (lastIntervalCount === interValCount) {
clearJobs = true; clearJobs = true;
console.log('new block')
} }
lastIntervalCount = interValCount; lastIntervalCount = interValCount;
@@ -263,7 +264,7 @@ export class StratumV1Client extends EasyUnsubscribe {
this.socket.write(job.response + '\n'); this.socket.write(job.response + '\n');
console.log(`Sent new job to ${this.extraNonce}. (clearJobs: ${clearJobs})`)
} }
@@ -284,7 +285,7 @@ export class StratumV1Client extends EasyUnsubscribe {
); );
const submissionDifficulty = this.calculateDifficulty(updatedJobBlock.toBuffer(true)); const submissionDifficulty = this.calculateDifficulty(updatedJobBlock.toBuffer(true));
console.log(`DIFF: ${submissionDifficulty} of ${this.sessionDifficulty}`); console.log(`DIFF: ${Math.round(submissionDifficulty)} of ${this.sessionDifficulty} from ${this.clientAuthorization.worker + '.' + this.extraNonce}`);
if (submissionDifficulty >= this.sessionDifficulty) { if (submissionDifficulty >= this.sessionDifficulty) {
@@ -323,14 +324,16 @@ export class StratumV1Client extends EasyUnsubscribe {
method: eResponseMethod.SET_DIFFICULTY, method: eResponseMethod.SET_DIFFICULTY,
params: [targetDiff] params: [targetDiff]
} }
) + '\n'); ) + '\n', () => {
// we need to clear the jobs so that the difficulty set takes effect. Otherwise the different miner implementations can cause issues // we need to clear the jobs so that the difficulty set takes effect. Otherwise the different miner implementations can cause issues
this.blockTemplateService.currentBlockTemplate$.pipe(take(1)).subscribe(({ blockTemplate }) => { this.blockTemplateService.currentBlockTemplate$.pipe(take(1)).subscribe(({ blockTemplate }) => {
this.sendNewMiningJob(blockTemplate, true); this.sendNewMiningJob(blockTemplate, true);
});
}); });
} }
} }
+6 -6
View File
@@ -63,18 +63,18 @@ export class StratumV1ClientStatistics {
} }
private blpo2(x) { private blpo2(val) {
x = x | (x >> 1); let x = val | (val >> 1);
x = x | (x >> 2); x = x | (x >> 2);
x = x | (x >> 4); x = x | (x >> 4);
x = x | (x >> 8); x = x | (x >> 8);
x = x | (x >> 16); x = x | (x >> 16);
x = x | (x >> 32); x = x | (x >> 32);
const val = x - (x >> 1); const res = x - (x >> 1);
if (val < 1) { if (res < 1) {
return 1; return this.blpo2(val * 100) / 100;
} }
return val; return res;
} }