-
Notifications
You must be signed in to change notification settings - Fork 299
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll also need to enable the bitswap interface-ipfs-core tests by adding a bitswap.spec.js
file here.
src/bitswap/unwant.js
Outdated
} else if (typeof args === 'string') { | ||
cid = new CID(args) | ||
} else { | ||
return callback(new Error('invalid argument')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's best not to call a callback in a try block. If the callback throws for whatever reason then it'll be caught and then the callback will be called again....which is really hard to debug.
You can just throw
here, it'll be caught and the callback will be called.
src/bitswap/wantlist.js
Outdated
} | ||
} catch (err) { | ||
return callback(err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see comments in unwant.js
about this try block
src/bitswap/unwant.js
Outdated
} | ||
} catch (err) { | ||
return callback(err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just wondering if there's a reason for the type detection here? It's a duplication of what's done in the CID constructor. Would it be possible to do this instead?:
let cid
try {
cid = new CID(args)
} catch (err) {
return callback(err)
}
send({
path: 'bitswap/unwant',
args: cid.toBaseEncodedString(),
qs: opts
}, callback)
3553804
to
056dda2
Compare
CID parsing is done just like block.add does This also removes the local tests and moves reliance on testing to the tests that are being added to interface-ipfs-core
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
056dda2
to
8d3f52a
Compare
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
Windows test failures are unrelated to this PR and are known swarm connection issues on Windows. I am investigating and am close to figuring out what the issue is. |
…fs-inactive#761) * fix(bitswap.unwant) Parse CID from arg * feat(bitswap.wantlist) add peer parameter * chore: simplify CID parsing for wantlist and unwant * chore: update interface-ipfs-core dependency * chore: upgrades interface-ipfs-core dependency License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
Adds peerid parameter to bitswap wantlist. Required for ipfs/js-ipfs#1349