address best diff

This commit is contained in:
Ben Wilson
2023-07-24 22:23:29 -04:00
parent 8369e9eef2
commit a4b4e517cb
7 changed files with 48 additions and 16 deletions
@@ -8,6 +8,9 @@ export class AddressSettingsEntity extends TrackedEntity {
@PrimaryColumn({ length: 62, type: 'varchar' })
address: string;
@Column({ type: 'real', default: 0 })
bestDifficulty: number
@Column()
miscCoinbaseScriptData: string;
@@ -14,4 +14,15 @@ export class AddressSettingsService {
}
public async getSettings(address: string) {
return await this.addressSettingsRepository.findOne({ where: { address } });
}
public async updateBestDifficulty(address: string, bestDifficulty: number) {
return await this.addressSettingsRepository.update({ address }, { bestDifficulty });
}
public async createNew(address: string) {
return await this.addressSettingsRepository.save({ address });
}
}
-8
View File
@@ -45,14 +45,6 @@ export class ClientService {
return await this.clientRepository.count();
}
public async getBestDiff(address: string) {
const res = await this.clientRepository.createQueryBuilder('client')
.select('MAX(client.bestDifficulty)', 'bestDifficulty')
.where('client.address = :address', { address })
.withDeleted()
.getRawOne();
return res?.bestDifficulty;
}
public async getByAddress(address: string): Promise<ClientEntity[]> {
return await this.clientRepository.find({
where: {