Ability to pin ipns names
It would be very nice to be able pin IPNS names, such that the daemon periodically polls the DHT to find if there are any new hashes published to the requested names, and then automatically pins them if so.
Depending on the structure of the code (I'm not familiar with Go), this may be a simple matter of creating a new thread to sit in a loop that does
while(running){
for each (name in pinned_names){
new_hash = resolve(name)
if(new_hash != last_good_known[name]){
pin(new_hash)
unpin(last_good_known[name])
last_good_known[name] = new_hash
}
}
sleep(something_sensible)
}
This would make it very easy to use IPFS as a backup solution, either to create a mirror of your website on another of your servers, or to make general backups to a remote machine (e.g. passworded duplicity backups would work quite well here).
Note that there should be some way within the command line syntax to allow the user to include a '-r' recursive pin/unpin option, for distinguishing if the user wants to pin a single node or the entire tree. Possible syntax could be something like ipfs pin name add -r
I've been thinking a little bit about this recently, and what my current train of thought is, is that once we implement pub-sub, updating an ipns entry will be a 'publish' that people can subscribe to, so they can be notified of every time it gets updated and then update the pin.
@whyrusleeping is it planned for the pin command to take an IPNS name and automatically pin the address pointed by the name and automatically unpin the old adress and pin the new one when the record is updated?
I think this has many usecases and should be taken into consideration, not sure about how hard it would be to implement but it doesn't look like it would need much except pub/sub.
@fazo96 yeah, something along those lines is planned. The issue is when to check for updates, its either polling or pubsub, and I really am not a fan of polling.
Right now when I try to pin IPNS path it just.. hangs and needs to be interrupted via Ctrl+C:
$ ipfs-node ipfs pin add /ipfs/QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D/example
pinned QmeKozNssnkJ4NcyRidYgDY2jfRZqVEoRGfipkgath71bX recursively
$ ipfs-node ipfs pin add /ipns/ipfs.git.sexy
^C
At this point it is not possible to pin anything else and I need to restart go-ipfs daemon to fix pinning functionality.
I think pinning a valid IPNS address should immediately return an error (Error: pin: IPNS not implemented yet), just like it does for invalid ones:
$ ipfs pin add /ipns/invalid.one
Error: pin: could not resolve name.
Hey. I'm also interested by that.
But do you think that pub-sub would be able to solve all the problem by itself ? If I pin an IPNS name, turn my node off and go back 10 days later, my node should do polling to poll for the last version of the content too as it may have missed pub/sub updates. Maybe something hybrid, where I could do either polling, pubsub, or both ?
Probably related issue: https://github.com/ipfs/go-ipfs/issues/4435
Is it true that trying to pin ipns path currently hangs, and also causes the daemon to not accept more pins, if so could we get a fix in that returns an error instead, or at least a warning? (that would avoid noobs like me spending lots of time wondering why/how pinning works and why it seems to hang) Thanks!
@NiKiZe pinning is a blocking operation, it fetches the data while holding the pin lock to ensure a garbage collection doesnt come along and wipe out the transfer progress. Because of this, while one thing is being pinned, another can't be pinned in the meantime.
We have plans on improving this moving forward
The pin lock is a read-write lock. This shouldn't be an issue (and I can't reproduce). The bug in question was reported before the pin lock was even introduced.
@whyrusleeping pointed out that there is a different lock.
My bad, pinning with /ipns/ seems to work, just (as explained why above) seemingly unresponsive, Thanks and sorry for the noise. (Looking forward to the ability to pin ipns and have it auto update)
Any progress on this?
shy bump would very much appreciate this :sweat_smile: Or is it also a use-case that is rather a "create your own service via boxo"?