mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
adjustments for cpuminer
This commit is contained in:
@@ -36,6 +36,7 @@ export class StratumV1Client {
|
|||||||
private clientAuthorization: AuthorizationMessage;
|
private clientAuthorization: AuthorizationMessage;
|
||||||
private clientSuggestedDifficulty: SuggestDifficulty;
|
private clientSuggestedDifficulty: SuggestDifficulty;
|
||||||
private stratumSubscription: Subscription;
|
private stratumSubscription: Subscription;
|
||||||
|
private backgroundWork: NodeJS.Timer;
|
||||||
|
|
||||||
private statistics: StratumV1ClientStatistics;
|
private statistics: StratumV1ClientStatistics;
|
||||||
private stratumInitialized = false;
|
private stratumInitialized = false;
|
||||||
@@ -82,6 +83,7 @@ export class StratumV1Client {
|
|||||||
|
|
||||||
public destroy() {
|
public destroy() {
|
||||||
this.stratumSubscription.unsubscribe();
|
this.stratumSubscription.unsubscribe();
|
||||||
|
clearInterval(this.backgroundWork);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getRandomHexString() {
|
private getRandomHexString() {
|
||||||
@@ -275,6 +277,12 @@ export class StratumV1Client {
|
|||||||
|
|
||||||
this.stratumInitialized = true;
|
this.stratumInitialized = true;
|
||||||
|
|
||||||
|
switch (this.clientSubscription.userAgent) {
|
||||||
|
case 'cpuminer': {
|
||||||
|
this.sessionDifficulty = 0.1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.clientSuggestedDifficulty == null) {
|
if (this.clientSuggestedDifficulty == null) {
|
||||||
console.log(`Setting difficulty to ${this.sessionDifficulty}`)
|
console.log(`Setting difficulty to ${this.sessionDifficulty}`)
|
||||||
@@ -297,14 +305,18 @@ export class StratumV1Client {
|
|||||||
).subscribe(async (jobTemplate) => {
|
).subscribe(async (jobTemplate) => {
|
||||||
try {
|
try {
|
||||||
await this.sendNewMiningJob(jobTemplate);
|
await this.sendNewMiningJob(jobTemplate);
|
||||||
await this.checkDifficulty();
|
|
||||||
await this.watchdog();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.promiseSocket.socket.emit('end', true);
|
this.promiseSocket.socket.emit('end', true);
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.backgroundWork = setInterval(async () => {
|
||||||
|
await this.checkDifficulty();
|
||||||
|
await this.watchdog();
|
||||||
|
}, 60 * 1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,7 +466,7 @@ export class StratumV1Client {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.checkDifficulty();
|
//await this.checkDifficulty();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,13 +52,13 @@ export class StratumV1ClientStatistics {
|
|||||||
public getSuggestedDifficulty(clientDifficulty: number) {
|
public getSuggestedDifficulty(clientDifficulty: number) {
|
||||||
|
|
||||||
// miner hasn't submitted shares in one minute
|
// miner hasn't submitted shares in one minute
|
||||||
if (this.submissionCache.length == 0 && (new Date().getTime() - this.submissionCacheStart.getTime()) / 1000 > 60) {
|
if (this.submissionCache.length == 0 || (new Date().getTime() - this.submissionCacheStart.getTime()) / 1000 > 60) {
|
||||||
return this.nearestPowerOfTwo(clientDifficulty >> 1);
|
return this.nearestPowerOfTwo(clientDifficulty >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.submissionCache.length < CACHE_SIZE) {
|
// if (this.submissionCache.length < CACHE_SIZE) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const sum = this.submissionCache.reduce((pre, cur) => {
|
const sum = this.submissionCache.reduce((pre, cur) => {
|
||||||
pre += cur.difficulty;
|
pre += cur.difficulty;
|
||||||
@@ -75,7 +75,6 @@ export class StratumV1ClientStatistics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private nearestPowerOfTwo(val): number {
|
private nearestPowerOfTwo(val): number {
|
||||||
|
|||||||
Reference in New Issue
Block a user