Skip to content

Commit

Permalink
refactor: use for...of instead of forEach (#6307)
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig authored Jan 16, 2024
1 parent 9940478 commit b082a48
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 @@ -963,9 +963,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 b082a48

Please sign in to comment.