mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
defer entity creation
This commit is contained in:
@@ -26,6 +26,9 @@ export class ClientStatisticsEntity extends TrackedEntity {
|
|||||||
@Column({ type: 'real' })
|
@Column({ type: 'real' })
|
||||||
shares: number;
|
shares: number;
|
||||||
|
|
||||||
|
@Column({ default: 0, type: 'integer' })
|
||||||
|
acceptedCount: number;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ export class ClientStatisticsService {
|
|||||||
const res1 = await this.clientStatisticsRepository.createQueryBuilder()
|
const res1 = await this.clientStatisticsRepository.createQueryBuilder()
|
||||||
.update(ClientStatisticsEntity)
|
.update(ClientStatisticsEntity)
|
||||||
.set({
|
.set({
|
||||||
shares: () => `"shares" + ${clientStatistic.shares}` // Use the actual value of shares here
|
shares: () => `"shares" + ${clientStatistic.shares}`, // Use the actual value of shares here
|
||||||
|
acceptedCount: () => `"acceptedCount" + 1`
|
||||||
})
|
})
|
||||||
.where('address = :address AND clientName = :clientName AND sessionId = :sessionId AND time = :time', { address: clientStatistic.address, clientName: clientStatistic.clientName, sessionId: clientStatistic.sessionId, time: clientStatistic.time })
|
.where('address = :address AND clientName = :clientName AND sessionId = :sessionId AND time = :time', { address: clientStatistic.address, clientName: clientStatistic.clientName, sessionId: clientStatistic.sessionId, time: clientStatistic.time })
|
||||||
.execute();
|
.execute();
|
||||||
|
|||||||
@@ -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(
|
this.stratumSubscription = this.stratumV1JobsService.newMiningJob$.pipe(
|
||||||
).subscribe(async (jobTemplate) => {
|
).subscribe(async (jobTemplate) => {
|
||||||
try {
|
try {
|
||||||
@@ -410,6 +401,18 @@ export class StratumV1Client {
|
|||||||
|
|
||||||
private async handleMiningSubmission(submission: MiningSubmitMessage) {
|
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);
|
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
|
// a miner may submit a job that doesn't exist anymore if it was removed by a new block notification
|
||||||
|
|||||||
Reference in New Issue
Block a user