From c41f3a9c5235ad564341035295f34b4c6f30b9ed Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Tue, 16 Jan 2024 16:22:00 +0100 Subject: [PATCH] refactor: use for...of instead of forEach (#6307) --- packages/beacon-node/src/chain/chain.ts | 4 ++-- packages/beacon-node/src/network/processor/index.ts | 4 +++- packages/fork-choice/src/forkChoice/forkChoice.ts | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/beacon-node/src/chain/chain.ts b/packages/beacon-node/src/chain/chain.ts index 448e55f3b8de..aee2068f6f70 100644 --- a/packages/beacon-node/src/chain/chain.ts +++ b/packages/beacon-node/src/chain/chain.ts @@ -965,9 +965,9 @@ export class BeaconChain implements IBeaconChain { } async updateBeaconProposerData(epoch: Epoch, proposers: ProposerPreparationData[]): Promise { - proposers.forEach((proposer) => { + for (const proposer of proposers) { this.beaconProposerCache.add(epoch, proposer); - }); + } } updateBuilderStatus(clockSlot: Slot): void { diff --git a/packages/beacon-node/src/network/processor/index.ts b/packages/beacon-node/src/network/processor/index.ts index 6fd0b235dfb1..ba84c9b12a60 100644 --- a/packages/beacon-node/src/network/processor/index.ts +++ b/packages/beacon-node/src/network/processor/index.ts @@ -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); } diff --git a/packages/fork-choice/src/forkChoice/forkChoice.ts b/packages/fork-choice/src/forkChoice/forkChoice.ts index 396146b193c7..32732e45fb6e 100644 --- a/packages/fork-choice/src/forkChoice/forkChoice.ts +++ b/packages/fork-choice/src/forkChoice/forkChoice.ts @@ -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 {