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:
parent
bf8b9bcbad
commit
db3535733d
@ -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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user