Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

feat(bitswap.unwant) expose bitswap.unwant to cli and http api #1306

Closed
wants to merge 2 commits into from

Conversation

wraithgar
Copy link
Contributor

@wraithgar wraithgar commented Apr 10, 2018

I have a few questions about this PR.

I can remove the print statement in this cli implementation and just test that no error happened instead if we want the output to match too.

@ghost ghost assigned wraithgar Apr 10, 2018
@ghost ghost added the status/in-progress In progress label Apr 10, 2018
@wraithgar
Copy link
Contributor Author

Tests were working when I checked this in now they're not, looking into why.

@wraithgar wraithgar force-pushed the bitswap_unwatch branch 2 times, most recently from 5417b46 to ae478c6 Compare April 10, 2018 19:57
@wraithgar wraithgar changed the title feat(bitswap.unwatch) expose bitswap.unwatch to cli and http api feat(bitswap.unwant) expose bitswap.unwatch to cli and http api Apr 10, 2018
@wraithgar wraithgar changed the title feat(bitswap.unwant) expose bitswap.unwatch to cli and http api feat(bitswap.unwant) expose bitswap.unwant to cli and http api Apr 10, 2018
@wraithgar
Copy link
Contributor Author

Got an email from Travis saying tests passed on this.

handler (argv) {
throw new Error('Not implemented yet')
argv.ipfs.bitswap.unwant(argv.key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be wrapped in a try/catch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the other cli files I looked at that use callbacks, if they get an error they just throw an error. I don't think the cli has a "catch and log to stderr" functionality in place.

I was using src/cli/commands/bitswap/wantlist.js and src/cli/commands/block/get.js as reference points on this because one is from the bitswap command list and the other is the "opposite" of unwant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're totally right that we don't have a pattern for handling failures on CLI. That's probably issue-able, I'll add it to a todo. My thought was that we at least shouldn't print('Key.. removed') after a failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell all failures will throw an exception so the print won't happen. Under the hood it's just removing an item from a set, once the CID validation passes (which would throw if there was an invalid key passed).

@dryajov
Copy link
Member

dryajov commented Apr 11, 2018

@wraithgar there seems to be a lint error that is failing your builds - npm run lint on the project should help solving those.

screen shot 2018-04-11 at 2 32 31 pm

@wraithgar
Copy link
Contributor Author

Thanks @dryajov. Fixed.

Linting in this repo is quite a pain as there are currently 91 linting problems reported when I run npm lint on master. Is there any plan to address these that you know of?

@dryajov
Copy link
Member

dryajov commented Apr 12, 2018

Yeah, those warnings should definitely be taken care of at some point, but I believe they are very low priority ATM. Not sure if anyone has taken the time to investigate them tho.

@daviddias
Copy link
Member

@wraithgar, thanks for submitting this PR. Yes, please update the spec -- https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BITSWAP.md -- with docs about this method.

@wraithgar
Copy link
Contributor Author

The remaining tests in test/core/bitswap.spec.js feel like they should be part of either the interface bitswap spec or at least renamed to test/core/block.spec.js as they deal specifically with calls to the block interface.

@daviddias
Copy link
Member

@wraithgar bitswap is the block exchange protocol, the block API calls are used to ensure that Bitswap is indeed doing its thing. Learn more about Bitswap at:

@wraithgar
Copy link
Contributor Author

This and the two PRs in interface and api are ready to go, as far as I can tell.

@daviddias
Copy link
Member

Please rebase master onto this branch for green CI

@wraithgar
Copy link
Contributor Author

This has been rebased w/ master.

Will require including the version of interface-ipfs-core that
they are moved to
@alanshaw
Copy link
Member

closing as this was superseded by #1349 (now merged)

@alanshaw alanshaw closed this Jun 20, 2018
@ghost ghost removed the status/in-progress In progress label Jun 20, 2018
@wraithgar wraithgar deleted the bitswap_unwatch branch June 20, 2018 14:46
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.

5 participants