Skip to content

Commit

Permalink
Parallelize fetching of funding index maps.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentwschau committed Oct 22, 2024
1 parent 72c423a commit 60639d9
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -589,16 +589,17 @@ async function getFundingIndexMapsChunked(
return parseInt(height, 10);
}).sort();
const aggregateFundingIndexMaps: {[blockHeight: string]: FundingIndexMap} = {};
for (const chunk of getHeightWindows(updatedAtHeightsNum)) {
await Promise.all(getHeightWindows(updatedAtHeightsNum).map(
async (heightWindow: number[]): Promise<void> => {
const fundingIndexMaps: {[blockHeight: string]: FundingIndexMap} = await
FundingIndexUpdatesTable
FundingIndexUpdatesTable
.findFundingIndexMaps(
chunk.map((heightNum: number): string => { return heightNum.toString(); }),
heightWindow.map((heightNum: number): string => { return heightNum.toString(); }),
);
for (const height of _.keys(fundingIndexMaps)) {
aggregateFundingIndexMaps[height] = fundingIndexMaps[height];
}
}
}));
return aggregateFundingIndexMaps;
}

Expand Down

0 comments on commit 60639d9

Please sign in to comment.