increment ids

This commit is contained in:
Ben Wilson
2023-06-17 09:25:50 -04:00
parent ca0668b807
commit f0dd027302
10 changed files with 199 additions and 187 deletions
+34
View File
@@ -0,0 +1,34 @@
import { Injectable } from '@nestjs/common';
import { MiningJob } from './models/MiningJob';
@Injectable()
export class StratumV1JobsService {
public latestJobId: number = 1;
public jobs: MiningJob[] = [];
public addJob(job: MiningJob, clearJobs: boolean) {
if (clearJobs) {
this.jobs = [];
}
this.jobs.push(job);
this.latestJobId++;
}
public getLatestJob() {
return this.jobs[this.jobs.length - 1];
}
public getJobById(jobId: string) {
return this.jobs.find(job => job.job_id == jobId);
}
public getNextId() {
return this.latestJobId.toString(16);
}
}