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

Commit

Permalink
fix: wait for one key to be the required key not all (#490)
Browse files Browse the repository at this point in the history
* fix: wait for one key to be the required key not all

Also, every returns true if there's no items in the list so this was returning a false positive.

* fix: iteratee not updating list
  • Loading branch information
Alan Shaw authored Jul 2, 2019
1 parent 2f8dc5c commit acea55f
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit acea55f

Please sign in to comment.