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

feat: invoke onProgress callback with events during routing #1975

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Aug 16, 2023

Allow passing an onProgress callback to the peer/content routers that can receive routing events.

Refs #1574

@achingbrain achingbrain marked this pull request as draft August 16, 2023 14:29
@achingbrain achingbrain changed the title feat: invoke onProgress callback with DHT queries during routing feat: invoke onProgress callback with events during routing Oct 24, 2023
@achingbrain achingbrain marked this pull request as ready for review October 25, 2023 08:47
@achingbrain achingbrain requested a review from a team as a code owner October 25, 2023 08:47
Copy link
Member

@maschad maschad left a comment

Choose a reason for hiding this comment

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

Looks good, some conflicts need to be resolved, but it is also strange to me that the interfaces are so verbose.

@@ -235,7 +244,15 @@ export interface Libp2pEvents<T extends ServiceMap = ServiceMap> {
* })
* ```
*/
'start': CustomEvent<Libp2p<T>>
'start': CustomEvent<Libp2p<
Copy link
Member

@maschad maschad Oct 25, 2023

Choose a reason for hiding this comment

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

This is pretty verbose, should we have this as a seperate interface?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not a massive fan of how this is implemented so I'm certainly open to suggestions of how to make it simpler.

The idea is to derive the types of content/peer routing progress events you'll get from the config so they can be type safe. I not sure it's reliably possible, and it leads to these sorts of generics contortions - we may be better off just making it untyped.

Copy link
Member

Choose a reason for hiding this comment

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

Yes I agree there, I don't see any type safety benefits as is, I think we are better off with

export interface Libp2pEvents<
  Services extends ServiceMap = ServiceMap,
  ProgressEvents extends ProgressEvent = ProgressEvent
> {
  'start': CustomEvent<Libp2p<Services, ProgressEvents>>;
  'stop': CustomEvent<Libp2p<Services, ProgressEvents>>;
}

given the DHTContentRouting class already specifies the ProgessEvent types in it's methods.

@achingbrain achingbrain marked this pull request as draft November 2, 2023 12:42
Allow passing an `onProgress` callback to the peer/content routers that can receive DHT query events.

Refs #1574
@dhuseby dhuseby added the help wanted Seeking public contribution on this issue label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Seeking public contribution on this issue
Projects
Status: 🪵Backlog
Development

Successfully merging this pull request may close these issues.

None yet

3 participants