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

feat: Bitswap wantlist peerid #761

Merged
merged 5 commits into from
Jun 18, 2018
Merged

feat: Bitswap wantlist peerid #761

merged 5 commits into from
Jun 18, 2018

Conversation

wraithgar
Copy link
Contributor

Adds peerid parameter to bitswap wantlist. Required for ipfs/js-ipfs#1349

@ghost ghost assigned wraithgar May 13, 2018
@ghost ghost added the in progress label May 13, 2018
Copy link
Contributor

@alanshaw alanshaw left a 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.

} else if (typeof args === 'string') {
cid = new CID(args)
} else {
return callback(new Error('invalid argument'))
Copy link
Contributor

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.

}
} catch (err) {
return callback(err)
}
Copy link
Contributor

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

}
} catch (err) {
return callback(err)
}
Copy link
Contributor

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)

@daviddias daviddias changed the title Bitswap wantlist peerid feat: Bitswap wantlist peerid May 29, 2018
@wraithgar wraithgar force-pushed the bitswap_wantlist_peerid branch 2 times, most recently from 3553804 to 056dda2 Compare June 8, 2018 18:43
wraithgar and others added 3 commits June 18, 2018 14:12
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>
@ghost ghost assigned alanshaw Jun 18, 2018
License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
@alanshaw
Copy link
Contributor

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.

@alanshaw alanshaw merged commit 73a153e into master Jun 18, 2018
@ghost ghost removed the in progress label Jun 18, 2018
@alanshaw alanshaw deleted the bitswap_wantlist_peerid branch June 18, 2018 16:03
danieldaf pushed a commit to danieldaf/js-ipfs-api that referenced this pull request Jul 21, 2018
…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>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants