Skip to content

Commit

Permalink
Merge pull request #57 from ATOR-Development/55-hardware-verification…
Browse files Browse the repository at this point in the history
…-shouldnt-filter-out-relay-metrics

Prevent duplicate fingerprints from being added to hardware bonus
  • Loading branch information
jim-toth authored Aug 20, 2024
2 parents 7f5ff03 + b328451 commit 8b3e685
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/distribution/distribution.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,20 @@ export class DistributionService {
}
}

public async getHardwareBonusFingerprints(): Promise<
DistributionState['bonuses']['hardware']['fingerprints']
> {
await this.refreshDreState()
if (this.dreState != undefined) {
return this.dreState?.bonuses.hardware.fingerprints || []
} else {
const {
cachedValue: { state }
} = await this.distributionContract.readState()
return state.bonuses.hardware.fingerprints || []
}
}

public async setRelayFamilies(
relays: ValidatedRelay[]
): Promise<VerificationResults> {
Expand Down Expand Up @@ -601,7 +615,14 @@ export class DistributionService {
public async setHardwareBonusRelays(
results: VerificationResults
): Promise<VerificationResults> {
const currentHardwareBonusFingerprints =
await this.getHardwareBonusFingerprints()
const fingerprints = results
.filter(
({ relay }) => !currentHardwareBonusFingerprints.includes(
relay.fingerprint
)
)
.filter(({ relay }) => relay.hardware_validated)
.map(({ relay }) => relay.fingerprint)

Expand Down

0 comments on commit 8b3e685

Please sign in to comment.