Skip to content

Commit

Permalink
chore: wrap list of tasks in promise.all
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Sep 20, 2019
1 parent 9bb5ea5 commit 4848b15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"benchmark": "^2.1.4",
"chai": "^4.2.0",
"dirty-chai": "^2.0.1",
"ipfs-repo": "ipfs/js-ipfs-repo#blockstore-accept-async-iterator",
"ipfs-repo": "^0.28.0",
"libp2p": "^0.26.1",
"libp2p-kad-dht": "^0.16.0",
"libp2p-mplex": "^0.8.0",
Expand Down
5 changes: 3 additions & 2 deletions src/decision-engine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class DecisionEngine {
const groupedTasks = groupBy(task => task.target.toB58String(), tasks)

const blocks = await Promise.all(uniqCids.map(cid => this.blockstore.get(cid)))
await Object.values(groupedTasks).map(async (tasks) => {

await Promise.all(Object.values(groupedTasks).map(async (tasks) => {
// all tasks in the group have the same target
const peer = tasks[0].target
const blockList = cids.map((cid) => blocks.find(b => b.cid.equals(cid)))
Expand All @@ -97,7 +98,7 @@ class DecisionEngine {
for (const block of blockList) {
this.messageSent(peer, block)
}
})
}))

this._tasks = []
}
Expand Down

0 comments on commit 4848b15

Please sign in to comment.