Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit 116d98e

Browse files
committed
fix bug | otimize call
1 parent a717271 commit 116d98e

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

packages/common/src/db/queries/Validators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ export const getValidatorActiveEras = async (
187187
// return the number of eras
188188
export const getIdentityValidatorActiveEras = async (
189189
address: string,
190+
validatorSets: ValidatorSet[],
190191
): Promise<number> => {
191192
const identityAddresses = await getIdentityAddresses(address);
192193
let count = 0;
193-
const validatorSets = await getAllValidatorSets();
194194
for (const era of validatorSets) {
195195
if (
196196
era.validators.some((validator) => identityAddresses.includes(validator))

packages/common/src/scorekeeper/jobs/specificJobs/EraStatsJob.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const eraStatsJob = async (
7676
updated: Date.now(),
7777
});
7878

79-
for (let i = currentEra; i > 20; i--) {
79+
for (let i = currentEra; i > currentEra - 20; i--) {
8080
if (await queries.validatorSetExistsForEra(i)) {
8181
continue;
8282
}

packages/common/src/utils/Validators.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { allCandidates, setRank } from "../db/queries";
1+
import { allCandidates, getAllValidatorSets, setRank } from "../db/queries";
22
import { queries } from "../index";
33

44
// Sets all validators ranks
55
export const setValidatorRanks = async () => {
66
const candidates = await allCandidates();
7+
const validatorSets = await getAllValidatorSets();
78
for (const candidate of candidates) {
89
const identityRank = await queries.getIdentityValidatorActiveEras(
910
candidate.stash,
11+
validatorSets,
1012
);
1113
await setRank(candidate.stash, identityRank);
1214
}

packages/gateway/src/services/Validator.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,3 @@ export const getValidatorsNumActiveEras = async (
3131
const eras = await queries.getValidatorActiveEras(stash);
3232
return eras;
3333
};
34-
35-
export const getIdentityValidatorNumActiveEras = async (
36-
stash: string,
37-
): Promise<any> => {
38-
const eras = await queries.getIdentityValidatorActiveEras(stash);
39-
return eras;
40-
};

0 commit comments

Comments
 (0)