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

Adding utility functions for Discovery interface #707

Open
aschmahmann opened this issue Aug 21, 2019 · 0 comments
Open

Adding utility functions for Discovery interface #707

aschmahmann opened this issue Aug 21, 2019 · 0 comments

Comments

@aschmahmann
Copy link
Collaborator

The Discovery interface is basically a generalized version of the Content Routing interface. The only differences are that Discovery handles strings instead of only CIDs and Discovery returns more information from its functions then Content Routing does.

Discovery: https://github.com/libp2p/go-libp2p-core/blob/f61804b905d3a0f75df0f03385e5ca5dbb801ad0/discovery/discovery.go
Content Routing: https://github.com/libp2p/go-libp2p-core/blob/f61804b905d3a0f75df0f03385e5ca5dbb801ad0/routing/routing.go

Therefore, it would be very helpful to have a set of utilities for working with multiple implementations of the Discovery interface together, just as we have for Content Routing (in libp2p/go-libp2p-routing-helpers).

One driving use case is to be able to pass multiple Discovery options into PubSub after /libp2p/go-libp2p-pubsub#184 lands as well as create configurable backoff/caching layers for the Discovery implementations.

Some useful utilities to add (probably to go-libp2p-discovery):

  1. Restricting an implementations use by key (similar to the LimitedValueStore)
  2. Utilizing multiple implementations together (similar to the Parallel router)
  3. Caching/Backoff with various strategies (e.g. None, Fixed, Exponential)
  4. Might also be nice to add a Content Router that is derived from a Discovery service, instead of just having the other way around. (Note: in principle this combined with the existing Discovery from Content Routing implementation would allow us to use the routing-helpers instead of create new ones. However, because the Discovery service has more information available and is more generic there would be some information loss.)

Unfortunately, Go's lack of generics makes reusing the routing-helpers code directly pretty difficult and basically requires us to fall back to something similar to copy-paste-edit. However, if there's interest I can try and make the internals reusable for a future modification of the routing-helpers.

Any thoughts @raulk @Stebalien

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

No branches or pull requests

1 participant