Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add maxtimeout to dht get #248

Merged
merged 2 commits into from
Sep 19, 2018
Merged

Conversation

vasco-santos
Copy link
Member

In the context of having the DHT enabled by default in js-ipfs, several problems were identified on js-ipfs/856#issuecomment-422495198. In this case, js-libp2p does not allow the definition of a maxTimeout.

NOTE: There are no tests for the DHT in js-ipfs, is there any reason?

@ghost ghost assigned vasco-santos Sep 19, 2018
@ghost ghost added the status/in-progress In progress label Sep 19, 2018
Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

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

Since the functions are changing in this PR we should make sure it doesn't break the current usage (even if the current usage is wrong). Let's check if maxTimeout is actually the callback and handle that accordingly.

We should also add basic mock dht tests to libp2p. We don't need to validate the dht, but we should be validating that when the dht is enabled and put,get,getMany are called with and without timeouts, that the mocks are properly called.

We should also verify we get errors when the dht is not enabled.

@vasco-santos vasco-santos force-pushed the fix/add-maxtimeout-to-dht-get branch from d076f49 to d3dd11f Compare September 19, 2018 16:59
@vasco-santos
Copy link
Member Author

hey @jacobheun

I updated the PR with your feedback 🙂

@jacobheun
Copy link
Contributor

Woot, looks good!

@jacobheun jacobheun merged commit 69f7264 into master Sep 19, 2018
@ghost ghost removed the status/in-progress In progress label Sep 19, 2018
@jacobheun jacobheun deleted the fix/add-maxtimeout-to-dht-get branch September 19, 2018 17:31
@@ -9,19 +9,29 @@ module.exports = (node) => {

node._dht.put(key, value, callback)
},
get: (key, callback) => {
get: (key, maxTimeout, callback) => {
Copy link
Member

Choose a reason for hiding this comment

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

things like timeouts should be in a options object rather than a arg otherwise you will fall into a future of having a huge array of options. @vasco-santos @jacobheun

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right! I will create a new PR for changing it here, as well as for js-libp2p-kad-dht and will change js-ipfs too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants