Skip to content

Commit 74e7e44

Browse files
committed
Parallelize the rates queries
1 parent 53d4129 commit 74e7e44

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/actions/ExchangeRateActions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ async function fetchExchangeRates(
309309
}
310310

311311
const requests = convertToRatesParams(cryptoPairMap, fiatPairMap)
312-
for (const query of requests) {
312+
const promises = requests.map(async query => {
313313
const options = {
314314
method: 'POST',
315315
headers: { 'Content-Type': 'application/json' },
@@ -399,14 +399,14 @@ async function fetchExchangeRates(
399399

400400
rateObj.expiration = rateExpiration
401401
}
402-
break
403402
}
404403
} catch (error: unknown) {
405404
console.log(
406405
`buildExchangeRates error querying rates server ${String(error)}`
407406
)
408407
}
409-
}
408+
})
409+
await Promise.allSettled(promises)
410410

411411
// Update the in-memory cache:
412412
exchangeRateCache = {

0 commit comments

Comments
 (0)