Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

fix: wait for one key to be the required key not all #490

Merged
merged 2 commits into from
Jul 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/bitswap/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ function waitForWantlistKey (ipfs, key, opts, cb) {

setTimeout(() => { timedOut = true }, opts.timeout)

const test = () => timedOut ? true : list.Keys.every(k => k['/'] === key)
const iteratee = (cb) => ipfs.bitswap.wantlist(opts.peerId, cb)
const test = () => timedOut ? true : list.Keys.some(k => k['/'] === key)
const iteratee = (cb) => {
ipfs.bitswap.wantlist(opts.peerId, (err, nextList) => {
if (err) return cb(err)
list = nextList
cb()
})
}

until(test, iteratee, (err) => {
if (err) return cb(err)
Expand Down