-
Notifications
You must be signed in to change notification settings - Fork 452
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
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.
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.
d076f49
to
d3dd11f
Compare
hey @jacobheun I updated the PR with your feedback 🙂 |
Woot, looks good! |
@@ -9,19 +9,29 @@ module.exports = (node) => { | |||
|
|||
node._dht.put(key, value, callback) | |||
}, | |||
get: (key, callback) => { | |||
get: (key, maxTimeout, callback) => { |
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.
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
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 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.
In the context of having the
DHT
enabled by default injs-ipfs
, several problems were identified on js-ipfs/856#issuecomment-422495198. In this case,js-libp2p
does not allow the definition of amaxTimeout
.maxTimeout
and thecallback
is lost.NOTE: There are no tests for the DHT in
js-ipfs
, is there any reason?