diff --git a/src/ORM/address-settings/address-settings.service.ts b/src/ORM/address-settings/address-settings.service.ts index da55722..ec3baab 100644 --- a/src/ORM/address-settings/address-settings.service.ts +++ b/src/ORM/address-settings/address-settings.service.ts @@ -14,9 +14,9 @@ export class AddressSettingsService { } - public async getSettings(address: string) { + public async getSettings(address: string, createIfNotFound: boolean) { const settings = await this.addressSettingsRepository.findOne({ where: { address } }); - if (settings == null) { + if (createIfNotFound == true && settings == null) { return await this.createNew(address); } return settings; diff --git a/src/controllers/client/client.controller.ts b/src/controllers/client/client.controller.ts index 530266b..80bbb96 100644 --- a/src/controllers/client/client.controller.ts +++ b/src/controllers/client/client.controller.ts @@ -20,7 +20,7 @@ export class ClientController { const workers = await this.clientService.getByAddress(address); - const addressSettings = await this.addressSettingsService.getSettings(address); + const addressSettings = await this.addressSettingsService.getSettings(address, false); return { bestDifficulty: addressSettings?.bestDifficulty, diff --git a/src/models/StratumV1Client.ts b/src/models/StratumV1Client.ts index 0d1edde..00007e7 100644 --- a/src/models/StratumV1Client.ts +++ b/src/models/StratumV1Client.ts @@ -524,7 +524,7 @@ export class StratumV1Client { if (submissionDifficulty > this.entity.bestDifficulty) { await this.clientService.updateBestDifficulty(this.extraNonceAndSessionId, submissionDifficulty); this.entity.bestDifficulty = submissionDifficulty; - if (submissionDifficulty > (await this.addressSettingsService.getSettings(this.clientAuthorization.address)).bestDifficulty) { + if (submissionDifficulty > (await this.addressSettingsService.getSettings(this.clientAuthorization.address, true)).bestDifficulty) { await this.addressSettingsService.updateBestDifficulty(this.clientAuthorization.address, submissionDifficulty); } }