mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
shares
This commit is contained in:
@@ -8,8 +8,11 @@ export class AddressSettingsEntity extends TrackedEntity {
|
|||||||
@PrimaryColumn({ length: 62, type: 'varchar' })
|
@PrimaryColumn({ length: 62, type: 'varchar' })
|
||||||
address: string;
|
address: string;
|
||||||
|
|
||||||
|
@Column({ default: 0 })
|
||||||
|
shares: number;
|
||||||
|
|
||||||
@Column({ type: 'real', default: 0 })
|
@Column({ type: 'real', default: 0 })
|
||||||
bestDifficulty: number
|
bestDifficulty: number;
|
||||||
|
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
miscCoinbaseScriptData: string;
|
miscCoinbaseScriptData: string;
|
||||||
|
|||||||
@@ -29,4 +29,22 @@ export class AddressSettingsService {
|
|||||||
public async createNew(address: string) {
|
public async createNew(address: string) {
|
||||||
return await this.addressSettingsRepository.save({ address });
|
return await this.addressSettingsRepository.save({ address });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async addShares(address: string, shares: number) {
|
||||||
|
return await this.addressSettingsRepository.createQueryBuilder()
|
||||||
|
.update(AddressSettingsEntity)
|
||||||
|
.set({
|
||||||
|
shares: () => `"shares" + :shares`
|
||||||
|
})
|
||||||
|
.where('address = :address', { address })
|
||||||
|
.setParameter('shares', shares)
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async resetBestDifficultyAndShares() {
|
||||||
|
return await this.addressSettingsRepository.update({}, {
|
||||||
|
shares: 0,
|
||||||
|
bestDifficulty: 0
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -387,10 +387,16 @@ export class StratumV1Client extends EasyUnsubscribe {
|
|||||||
sessionId: this.extraNonceAndSessionId,
|
sessionId: this.extraNonceAndSessionId,
|
||||||
blockData: blockHex
|
blockData: blockHex
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.notificationService.notifySubscribersBlockFound(this.clientAuthorization.address, jobTemplate.blockData.height, updatedJobBlock, result);
|
await this.notificationService.notifySubscribersBlockFound(this.clientAuthorization.address, jobTemplate.blockData.height, updatedJobBlock, result);
|
||||||
|
//success
|
||||||
|
if (result == null) {
|
||||||
|
await this.addressSettingsService.resetBestDifficultyAndShares();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await this.statistics.addSubmission(this.entity, submissionHash, this.sessionDifficulty);
|
await this.statistics.addSubmission(this.entity, submissionHash, this.sessionDifficulty);
|
||||||
|
await this.addressSettingsService.addShares(this.clientAuthorization.address, this.sessionDifficulty);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
const err = new StratumErrorMessage(
|
const err = new StratumErrorMessage(
|
||||||
|
|||||||
Reference in New Issue
Block a user