mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
update postgresql branch
This commit is contained in:
@@ -162,6 +162,32 @@ export class StratumV1JobsService {
|
||||
return this.blocks[jobTemplateId];
|
||||
}
|
||||
|
||||
public cleanup(clearJobs: boolean, now: number = Date.now()) {
|
||||
if (clearJobs) {
|
||||
this.blocks = {};
|
||||
this.jobs = {};
|
||||
return;
|
||||
}
|
||||
|
||||
let templatesDeleted = 0;
|
||||
let jobsDeleted = 0;
|
||||
|
||||
for (const templateId in this.blocks) {
|
||||
if (now - this.blocks[templateId].blockData.creation > (1000 * 60 * 5)) {
|
||||
delete this.blocks[templateId];
|
||||
templatesDeleted++;
|
||||
}
|
||||
}
|
||||
|
||||
for (const jobId in this.jobs) {
|
||||
if (now - this.jobs[jobId].creation > (1000 * 60 * 5)) {
|
||||
delete this.jobs[jobId];
|
||||
jobsDeleted++;
|
||||
}
|
||||
}
|
||||
//console.log(`Deleted ${templatesDeleted} templates and ${jobsDeleted} jobs.`)
|
||||
}
|
||||
|
||||
public addJob(job: MiningJob) {
|
||||
this.jobs[job.jobId] = job;
|
||||
this.latestJobId++;
|
||||
@@ -178,5 +204,4 @@ export class StratumV1JobsService {
|
||||
return this.latestJobId.toString(16);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user