1
0
mirror of https://github.com/dap-ps/discover.git synced 2025-01-31 03:26:13 +00:00

run infura calls in parallel, not sequentially (#57)

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-12-12 21:15:41 +01:00 committed by Andy Tudhope
parent bf8b9bcbad
commit db3535733d

View File

@ -59,13 +59,14 @@ class DiscoverService extends BlockchainService {
const dappsCache = JSON.parse(
JSON.stringify(await MetadataClient.retrieveMetadataCache()),
)
const dapps = []
for (let i = 0; i < contractDappsCount; i++) {
const dapp = await DiscoverContract.methods
.dapps(i)
.call({ from: this.sharedContext.account })
let asyncCalls = [...Array(contractDappsCount).keys()].map(
i => DiscoverContract.methods.dapps(i).call({ from: this.sharedContext.account })
)
/* using Promise.all() to run calls in parallel */
let dapps = await Promise.all(asyncCalls)
for (let dapp of dapps) {
const dappMetadata = dappsCache[dapp.metadata]
if (dappMetadata) {
delete dappsCache[dapp.metadata]