mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
promise socket end
This commit is contained in:
@@ -69,7 +69,7 @@ export class StratumV1Client {
|
|||||||
try {
|
try {
|
||||||
await this.handleMessage(m);
|
await this.handleMessage(m);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.promiseSocket.socket.emit('end', true);
|
await this.promiseSocket.end();
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -107,7 +107,7 @@ export class StratumV1Client {
|
|||||||
parsedMessage = JSON.parse(message);
|
parsedMessage = JSON.parse(message);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Invalid JSON");
|
console.log("Invalid JSON");
|
||||||
this.promiseSocket.socket.emit('end', true);
|
await this.promiseSocket.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,16 +310,12 @@ export class StratumV1Client {
|
|||||||
try {
|
try {
|
||||||
await this.sendNewMiningJob(jobTemplate);
|
await this.sendNewMiningJob(jobTemplate);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.promiseSocket.socket.emit('end', true);
|
await this.promiseSocket.end();
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.backgroundWork = setInterval(async () => {
|
this.backgroundWork = setInterval(async () => {
|
||||||
if (this.promiseSocket.isPromiseWritable == false) {
|
|
||||||
this.destroy();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await this.checkDifficulty();
|
await this.checkDifficulty();
|
||||||
//await this.watchdog();
|
//await this.watchdog();
|
||||||
}, 60 * 1000);
|
}, 60 * 1000);
|
||||||
@@ -337,7 +333,7 @@ export class StratumV1Client {
|
|||||||
// // one hour
|
// // one hour
|
||||||
// if (diffSeconds > 60 * 60) {
|
// if (diffSeconds > 60 * 60) {
|
||||||
// console.log(`Watchdog ending session ${this.extraNonceAndSessionId}}`);
|
// console.log(`Watchdog ending session ${this.extraNonceAndSessionId}}`);
|
||||||
// this.promiseSocket.socket.emit('end', true);
|
// await this.promiseSocket.end();
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@@ -467,7 +463,7 @@ export class StratumV1Client {
|
|||||||
try {
|
try {
|
||||||
await this.promiseSocket.write(err);
|
await this.promiseSocket.write(err);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.promiseSocket.socket.emit('end', true);
|
await this.promiseSocket.end();
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -494,7 +490,12 @@ export class StratumV1Client {
|
|||||||
params: [targetDiff]
|
params: [targetDiff]
|
||||||
}) + '\n';
|
}) + '\n';
|
||||||
|
|
||||||
await this.promiseSocket.write(data);
|
try {
|
||||||
|
await this.promiseSocket.write(data);
|
||||||
|
} catch (e) {
|
||||||
|
await this.promiseSocket.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
const jobTemplate = await firstValueFrom(this.stratumV1JobsService.newMiningJob$);
|
const jobTemplate = await firstValueFrom(this.stratumV1JobsService.newMiningJob$);
|
||||||
|
|||||||
Reference in New Issue
Block a user