-
Notifications
You must be signed in to change notification settings - Fork 446
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: invoke onProgress callback with DHT queries during routing #1652
fix: invoke onProgress callback with DHT queries during routing #1652
Conversation
Allow passing an `onProgress` callback to the peer/content routers that can receive DHT query events. Experimental for now.
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.
ProgessEvents! Woot!
src/dht/dht-content-routing.ts
Outdated
for await (const event of this.dht.findProviders(cid, options)) { | ||
options.onProgress?.(new CustomProgressEvent('content-routing:find-providers:dht:event', event)) |
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.
We could extract these event names to be const
s and then reuse them.
|
||
const onProgress = sinon.stub() | ||
|
||
await drain(nodes[0].contentRouting.findProviders(CID.parse('QmU621oD8AhHw6t25vVyfYKmL9VV3PTgc52FngEhTGACFB'), { |
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.
Where did this CID come from?
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 used elsewhere in the test suite 🤷
Converted to draft because we need to be a bit cleverer about how we expose the If we don't expose them all we get errors: await name.resolve(key, {
onProgress(evt) {
if (evt.type === 'content-routing:get:dht:event') {
}
}
})
The problem is we want to avoid exposing all the ProgressEvent types for all the content routing/peer routing implementations at the content routing/peer routing interface level. Better to somehow aggregate the types based on the configuration passed to the libp2p factory function in a similar way to #1563 |
Closing in favour of #1975 |
Allow passing an
onProgress
callback to the peer/content routers that can receive DHT query events.Refs #1574