Skip to content

Commit

Permalink
Loop batches sequentially instead of Promise.all()
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Jun 28, 2021
1 parent 4705616 commit 3ce3cf6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/validator/src/services/indices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ export class IndicesService {
const pubkeysHex = pubkeysToPoll.map((pubkey) => toHexString(pubkey)).slice(0, MAX_PUBKEYS_PER_POLL);
const batches = pubkeysToBatches(pubkeysHex);

const newIndicesArr = await Promise.all(
batches.map(async (batch) => {
const validatorIndicesArr = await Promise.all(batch.map(this.getIndicesPerHttpRequest));
return validatorIndicesArr.flat();
})
);
const newIndicesArr = [];
for (const batch of batches) {
const validatorIndicesArr = await Promise.all(batch.map(this.getIndicesPerHttpRequest));
newIndicesArr.push(...validatorIndicesArr.flat());
}
const newIndices = newIndicesArr.flat();
this.logger.info("Discovered new validators", {count: newIndices.length});
return newIndices;
Expand Down

0 comments on commit 3ce3cf6

Please sign in to comment.