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

Commit acea55f

Browse files
author
Alan Shaw
authored
fix: wait for one key to be the required key not all (#490)
* 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
1 parent 2f8dc5c commit acea55f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/bitswap/utils.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ function waitForWantlistKey (ipfs, key, opts, cb) {
1616

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

19-
const test = () => timedOut ? true : list.Keys.every(k => k['/'] === key)
20-
const iteratee = (cb) => ipfs.bitswap.wantlist(opts.peerId, cb)
19+
const test = () => timedOut ? true : list.Keys.some(k => k['/'] === key)
20+
const iteratee = (cb) => {
21+
ipfs.bitswap.wantlist(opts.peerId, (err, nextList) => {
22+
if (err) return cb(err)
23+
list = nextList
24+
cb()
25+
})
26+
}
2127

2228
until(test, iteratee, (err) => {
2329
if (err) return cb(err)

0 commit comments

Comments
 (0)