Skip to content

Commit

Permalink
refactor: use for...of instead of forEach (ChainSafe#6307)
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig authored and ensi321 committed Jan 22, 2024
1 parent c4eaa33 commit c41f3a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/beacon-node/src/chain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -965,9 +965,9 @@ export class BeaconChain implements IBeaconChain {
}

async updateBeaconProposerData(epoch: Epoch, proposers: ProposerPreparationData[]): Promise<void> {
proposers.forEach((proposer) => {
for (const proposer of proposers) {
this.beaconProposerCache.add(epoch, proposer);
});
}
}

updateBuilderStatus(clockSlot: Slot): void {
Expand Down
4 changes: 3 additions & 1 deletion packages/beacon-node/src/network/processor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,9 @@ export class NetworkProcessor {
];

if (Array.isArray(messageOrArray)) {
messageOrArray.forEach((msg) => this.trackJobTime(msg, messageOrArray.length));
for (const msg of messageOrArray) {
this.trackJobTime(msg, messageOrArray.length);
}
} else {
this.trackJobTime(messageOrArray, 1);
}
Expand Down
4 changes: 3 additions & 1 deletion packages/fork-choice/src/forkChoice/forkChoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,9 @@ export class ForkChoice implements IForkChoice {
onAttesterSlashing(attesterSlashing: phase0.AttesterSlashing): void {
// TODO: we already call in in state-transition, find a way not to recompute it again
const intersectingIndices = getAttesterSlashableIndices(attesterSlashing);
intersectingIndices.forEach((validatorIndex) => this.fcStore.equivocatingIndices.add(validatorIndex));
for (const validatorIndex of intersectingIndices) {
this.fcStore.equivocatingIndices.add(validatorIndex);
}
}

getLatestMessage(validatorIndex: ValidatorIndex): LatestMessage | undefined {
Expand Down

0 comments on commit c41f3a9

Please sign in to comment.