Open guillaumemichel opened 1 year ago
This issue will probably be followed up by an IPIP
I don't see why this will require an IPIP, IIUC there are no spec things here. This is just agreement on what some Go code should look like so we can use multiple content advertising systems sanely.
StartProvide(CIDs)
StartProvide(CID); StartProvide(CID); StopProvide(CID)
?
ListProvides
We'll need to define the atomicity guarantees and guarantees around duplicates here. I'm not sure how this function is planned to be used, so probably easier to define things here after Start/Stop are well defined.
What is the expected behavior around if the same CID is provided twice?
I would propose it's idempotent
There should be a contract with Start/Stop around atomicity. What's supposed to happen if the program dies in the middle of the operation?
I would propose the contract is that nothing is promised until the method returns. failing during execution means state is left in an undefined state, and it is the caller's responsibility to re-call the method (see idempotency above)
I would propose the contract is that nothing is promised until the method returns. failing during execution means state is left in an undefined state, and it is the caller's responsibility to re-call the method (see idempotency above)
I think it's better if it's eventually transactional, if StartProvide
fails none of the CIDs are provided, it is fine if temporarily some CIDs are provided but eventually they must not. (this allows to parallelise writing to a database while doing DHT provides for example, if writing to the DB fail no CID is enqueued and whatever has been provided until there will stop being provided in ~1 day).
I would propose it's idempotent
I agree with @willscott
I can see multiple ways forward:
Delegated Responsibility:
StartProvide([]cid.Cid)
, the function returns immediately.ProvideStatus(cid.Cid)
, can be queried to get the status of a specific CID's advertisement. This method might return statuses like advertised
, pending
, retrying
, or failed
.Caller's Responsibility:
StartProvide([]cid.Cid) error
will return nil
if all the CIDs were advertised successfully.error
is returned.Channel-based Feedback:
StartProvide([]cid.Cid) chan update
returns a channel that provides real-time updates regarding the state of the CID advertisements.ProvideStatus(cid.Cid)
, can be queried to get the status of a specific CID's advertisement. This method might return statuses like advertised
, pending
, retrying
, or failed
.I have a preference for 3b because the retry logic may be content router specific and the application should make no assumption on the content router. Also 3b keeps the application informed of ongoing statuses, facilitating informed decision-making. This approach strikes a balance between delegation and oversight.
cc @gammazero
Checklist
Description
Problem Statement:
Currently, Kubo is responsible for managing the DHT's provide and reprovide operations. However, with the evolution of Content Routers beyond just the DHT, it's evident that the existing mechanism is not optimal. The reasons are:
Proposed Solution
To better streamline the providing mechanism across different content routers, we propose a unified interface that shifts the responsibility from Kubo to the individual content routers. The proposed interface includes:
StartProvide(CIDs)
: Instructs the content router to begin advertising that the Kubo node is storing the specified CIDs. This advertisement (or republishing) should continue until aStopProvide
is invoked for these CIDs.StopProvide(CIDs)
: Commands the content router to cease the advertisement for the given CIDs.ListProvides
: Returns the list of CIDs currently being advertised by the content router.Benefits
Feedback and Collaboration
The proposed interface is just a draft for now. The goal of this issue is to gather feedback and start a public discussion about specific interface needs for different content routers, especially IPNI and the DHT. This issue will probably be followed up by an IPIP in ipfs/specs, once we have listed the requirements of all (known) Content Routers.
References
cc: @masih @ischasny @aschmahmann @Jorropo @dennis-tra @iand