Skip to content

Provider interface #1093

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

Open
wants to merge 2 commits into
base: reprovide-sweep
Choose a base branch
from
Open

Conversation

guillaumemichel
Copy link
Contributor

@guillaumemichel guillaumemichel commented Jun 25, 2025

This PR is just a place to discuss the interface, it doesn't contain actual code.

DHT Provider Interface

Here is the suggested Provider interface for the SweepingReprovider, to be used in kubo to replace boxo/provider System/Provider interface.

Note that the interface would also be implemented by a dual DHT Sweeping Provider.

We can extend the interface as needed (e.g Stats()).


Kubo integration

If we want both Provide systems (go-libp2p-kad-dht:Provider and boxo:Provider) to be swappable in kubo (at least for a transition period), it would be convenient to have a common interface for both systems.

IMO it is easier to wrap boxo:Provider around go-libp2p-kad-dht:Provider than the other way around, since go-libp2p-kad-dht:Provider is "richer".

However, go-libp2p-kad-dht:Provider doesn't have a concept of Reprovide to trigger a general reprovide of all keys, which is required by boxo:Provider. AFAIK only the ipfs routing reprovide command is using boxo:Provider.Reprovide, so it should be easy enough to cast and if the provide system in use in kubo is boxo:Provider, the reprovide command happens as it used to, otherwise mark it as deprecated with the new provide system.

If boxo:Provider is wrapped in the go-libp2p-kad-dht:Provider interface, StartProviding(), InstantProvide() and ForceProvide() could be mapped to boxo:Provider.Provide(), and StopProviding() would be a noop.


@lidel @hsanjuan @gammazero WDYT? We can still change the interface easily at this point.

## Suggested `SweepingReprovider` interface

```go
type Provider interface {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This interface is currently named Reprovider, in go-libp2p-kad-dht/reprovider.

I figured the name Provider makes more sense since its users only need to know that this is a content routing provider. They don't need to know the internals of whether the content has to be reprovided. The goal is to signal that the Provider takes the responsibility to advertise content as needed to the remote content routing system (DHT here).

I initially chose Reprovider because go-libp2p-kad-dht/providers/ already exists, and because kubo Provider is the old boxo providing system. I now think it makes more sense to use Provider.

Copy link
Contributor

@gammazero gammazero left a comment

Choose a reason for hiding this comment

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

I think that a Provider interface makes most sense.


// ForceProvide is similar to StartProviding, but it sends provider records out
// to the DHT even if the keys were already provided in the past.
ForceProvide(context.Context, ...mh.Multihash) error
Copy link
Member

@lidel lidel Jul 8, 2025

Choose a reason for hiding this comment

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

nit: name tbd, but should reflect this is ing version that needs to be stopped

Suggested change
ForceProvide(context.Context, ...mh.Multihash) error
StartProvidingAndForceInstantProvide(context.Context, ...mh.Multihash) error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ForceStartProviding?

Copy link
Contributor

@hsanjuan hsanjuan left a comment

Choose a reason for hiding this comment

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

I wrote this a few day ago. Mostly comments about namings. Along same lines of more recent comments.


// ForceProvide is similar to StartProviding, but it sends provider records out
// to the DHT even if the keys were already provided in the past.
ForceProvide(context.Context, ...mh.Multihash) error
Copy link
Contributor

Choose a reason for hiding this comment

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

Not saying it must, but perhaps can be merged into StartProviding(ctx, now bool, mh.Multihash)

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternative names ProvideNow or just Provide.

Very explicit: ImmediateSingleProvide().

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.

4 participants