Having worked on the Pinner in various way (including alternate implementation), it occurred to me that it really shouldn't be tasked to:
- write the root block into storage in
Pin(): https://github.com/ipfs/go-ipfs-pinner/blob/72f5e02e73db5e05ef0a140a7938cbc89dfc38b0/dspinner/pin.go#L177
- fetch the full DAG in
Pin(): https://github.com/ipfs/go-ipfs-pinner/blob/72f5e02e73db5e05ef0a140a7938cbc89dfc38b0/dspinner/pin.go#L202
This is for different (not obvious, I admit) reasons:
- often, the caller side know if the blocks are local or not. In any case, it's trivial to fetch the blocks on the caller side if not.
- that would allow to merge
Pin and PinWithMode and simplify the API
- this hurts composability in weird scenario like mine, where you want to control where that fetching is happening, and where the blocks are going (aka, not necessarily in the normal DAGService)
- it might avoid double writes
- it seems like this pain is already felt within kubo: https://github.com/ipfs/kubo/blob/82467bc936fe24355c930f7226fce7e41fee591c/core/commands/dag/import.go#L73-L87
Admittedly, things have worked that way for a long time, but fixing that might help in the long run. Looking at where Pin is called in kubo, it also looks like a non-invasive change.
Having worked on the Pinner in various way (including alternate implementation), it occurred to me that it really shouldn't be tasked to:
Pin(): https://github.com/ipfs/go-ipfs-pinner/blob/72f5e02e73db5e05ef0a140a7938cbc89dfc38b0/dspinner/pin.go#L177Pin(): https://github.com/ipfs/go-ipfs-pinner/blob/72f5e02e73db5e05ef0a140a7938cbc89dfc38b0/dspinner/pin.go#L202This is for different (not obvious, I admit) reasons:
PinandPinWithModeand simplify the APIAdmittedly, things have worked that way for a long time, but fixing that might help in the long run. Looking at where
Pinis called in kubo, it also looks like a non-invasive change.