I am trying to add a file using the ipfs-cluster client (github.com/ipfs/ipfs-cluster/api/rest/client) and am unsure on how the Add method actually works. When running a local cluster of 4 nodes, the Add function does not returned (I waited until 10 minutes), but I shortly get an output in the AddedOutput. I guess I am missing something and not using the API correctly.
func AddFile(c client.Client, path string) string {
ctx := context.Background()
out := make(chan *api.AddedOutput)
paths := []string{path}
go c.Add(ctx, paths, api.DefaultAddParams(), out)
ao := <-out
return ao.Cid.String()
}
In the Add implementation, the following is mentioned:
The output channel will receive regular updates as the adding process progresses.
What do these updates mean, and when are they sent ?
When exactly is the Add function supposed to return ?
Is there a detailed doc of the ipfs-cluster Add process ?
you are creating a channel with no capacity and you are only reading one value out of it. Iām guessing things are stuck because the other side cannot put more things in the channel.
I have to redirect you here:
Make a channel with some buffer capacity
for-loop reading from the channel to receive all the progress updates until the channel is closed (adding finished or an error happened).
The last message from the channel will always be the final root CID.