mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
optimizations
This commit is contained in:
@@ -75,7 +75,7 @@ export class StratumV1Client extends EasyUnsubscribe {
|
||||
});
|
||||
|
||||
this.sessionStart = new Date();
|
||||
this.statistics = new StratumV1ClientStatistics(this.clientStatisticsService);
|
||||
this.statistics = new StratumV1ClientStatistics(this.clientStatisticsService, this.clientService);
|
||||
this.extraNonceAndSessionId = this.getRandomHexString();
|
||||
console.log(`New client ID: : ${this.extraNonceAndSessionId}`);
|
||||
}
|
||||
@@ -349,8 +349,11 @@ export class StratumV1Client extends EasyUnsubscribe {
|
||||
|
||||
this.stratumV1JobsService.addJob(job);
|
||||
|
||||
|
||||
await this.promiseSocket.write(job.response(jobTemplate));
|
||||
try {
|
||||
await this.promiseSocket.write(job.response(jobTemplate));
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
|
||||
console.log(`Sent new job to ${this.clientAuthorization.worker}.${this.extraNonceAndSessionId}. (clearJobs: ${jobTemplate.blockData.clearJobs}, fee?: ${!noFee})`)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ClientStatisticsService } from '../ORM/client-statistics/client-statistics.service';
|
||||
import { ClientEntity } from '../ORM/client/client.entity';
|
||||
import { ClientService } from '../ORM/client/client.service';
|
||||
|
||||
const CACHE_SIZE = 30;
|
||||
const TARGET_SUBMISSION_PER_SECOND = 10;
|
||||
@@ -9,7 +10,10 @@ export class StratumV1ClientStatistics {
|
||||
private submissionCacheStart: Date;
|
||||
private submissionCache = [];
|
||||
|
||||
constructor(private readonly clientStatisticsService: ClientStatisticsService) {
|
||||
constructor(
|
||||
private readonly clientStatisticsService: ClientStatisticsService,
|
||||
private readonly clientService: ClientService
|
||||
) {
|
||||
this.submissionCacheStart = new Date();
|
||||
}
|
||||
|
||||
@@ -38,6 +42,9 @@ export class StratumV1ClientStatistics {
|
||||
submissionHash
|
||||
});
|
||||
|
||||
await this.clientService.heartbeat(client.address, client.clientName, client.sessionId)
|
||||
|
||||
|
||||
}
|
||||
public getLastSubmissionTime(): Date | null {
|
||||
return this.submissionCache[this.submissionCache.length - 1]?.time;
|
||||
|
||||
Reference in New Issue
Block a user