defer entity creation

This commit is contained in:
Ben Wilson
2023-08-07 10:15:16 -04:00
parent d4ec2ab3b4
commit 32c5545de8
3 changed files with 17 additions and 10 deletions
+12 -9
View File
@@ -340,15 +340,6 @@ export class StratumV1Client {
}
this.entity = await this.clientService.insert({
sessionId: this.extraNonceAndSessionId,
address: this.clientAuthorization.address,
clientName: this.clientAuthorization.worker,
userAgent: this.clientSubscription.userAgent,
startTime: new Date(),
bestDifficulty: 0
});
this.stratumSubscription = this.stratumV1JobsService.newMiningJob$.pipe(
).subscribe(async (jobTemplate) => {
try {
@@ -410,6 +401,18 @@ export class StratumV1Client {
private async handleMiningSubmission(submission: MiningSubmitMessage) {
if (this.entity == null) {
this.entity = await this.clientService.insert({
sessionId: this.extraNonceAndSessionId,
address: this.clientAuthorization.address,
clientName: this.clientAuthorization.worker,
userAgent: this.clientSubscription.userAgent,
startTime: new Date(),
bestDifficulty: 0
});
}
const job = this.stratumV1JobsService.getJobById(submission.jobId);
// a miner may submit a job that doesn't exist anymore if it was removed by a new block notification