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

Commit 5b4a29f

Browse files
authored
Merge pull request #2867 from w3f/will-update-eras
Query only past 84 eras of Era Points
2 parents 0e8cda5 + 9e6668c commit 5b4a29f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

packages/common/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,5 @@ export const USE_PROVIDER = true;
207207
export const USE_NOMINATIONS = true;
208208
export const USE_RPC = true;
209209
export const USE_CLIENT = true;
210+
211+
export const ERAPOINTS_JOB_MAX_ERAS = 84;

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChainData, logger, queries } from "../../../index";
1+
import { ChainData, Constants, logger, queries } from "../../../index";
22
import { Job, JobConfig, JobRunnerMetadata, JobStatus } from "../JobsClass";
33
import { jobStatusEmitter } from "../../../Events";
44
import { withExecutionTimeLogging } from "../../../utils";
@@ -63,16 +63,15 @@ export const eraPointsJob = async (
6363
// - if a record doesn't exist, create it
6464
const [activeEra, err] = await chaindata.getActiveEraIndex();
6565

66-
// Calculate total number of eras to process
67-
const totalEras = activeEra;
68-
let processedEras = 0;
69-
70-
for (let i = activeEra - 1; i >= 0; i--) {
66+
for (
67+
let i = activeEra - 1, processedEras = 1;
68+
i >= activeEra - Constants.ERAPOINTS_JOB_MAX_ERAS;
69+
i--, processedEras++
70+
) {
7171
await individualEraPointsJob(chaindata, i);
7272

7373
// Calculate progress percentage
74-
processedEras++;
75-
const progress = (processedEras / totalEras) * 100;
74+
const progress = (processedEras / Constants.ERAPOINTS_JOB_MAX_ERAS) * 100;
7675

7776
// Emit progress update with active era as iteration
7877
jobStatusEmitter.emit("jobProgress", {

0 commit comments

Comments
 (0)