Skip to content

Commit fbb2d73

Browse files
committed
set concurrency to 1 in .map network calls
1 parent 199e8ef commit fbb2d73

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

package-lock.json

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@liquality/ethereum-swap-provider": "^0.6.3",
4040
"bignumber.js": "^9.0.0",
4141
"bip39": "^3.0.2",
42+
"bluebird": "^3.7.2",
4243
"bootstrap": "^4.5.0",
4344
"core-js": "^3.6.4",
4445
"crypto-js": "^4.0.0",
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import Bluebird from 'bluebird'
2+
13
export const getUnusedAddresses = async ({ commit, getters }, { network, walletId, assets }) => {
2-
return Promise.all(assets.map(async asset => {
4+
return Bluebird.map(assets, async asset => {
35
const result = await getters.client(network, walletId, asset).wallet.getUnusedAddress()
46
const address = result.address
57

68
commit('UPDATE_UNUSED_ADDRESS', { network, walletId, asset, address })
79

810
return address
9-
}))
11+
}, { concurrency: 1 })
1012
}

src/store/actions/updateBalances.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import Bluebird from 'bluebird'
12
import { NetworkAssets } from '../factory/client'
23

34
export const updateBalances = async ({ commit, getters }, { network, walletId }) => {
45
const assets = NetworkAssets[network]
56

6-
return Promise.all(assets
7-
.map(async asset => {
8-
const addresses = await getters.client(network, walletId, asset).wallet.getUsedAddresses()
9-
const balance = (await getters.client(network, walletId, asset).chain.getBalance(addresses)).toNumber()
7+
return Bluebird.map(assets, async asset => {
8+
const addresses = await getters.client(network, walletId, asset).wallet.getUsedAddresses()
9+
const balance = (await getters.client(network, walletId, asset).chain.getBalance(addresses)).toNumber()
1010

11-
commit('UPDATE_BALANCE', { network, walletId, asset, balance })
12-
}))
11+
commit('UPDATE_BALANCE', { network, walletId, asset, balance })
12+
}, { concurrency: 1 })
1313
}

0 commit comments

Comments
 (0)