I have been trying to get my head around how IPNS works.
From what I can ascertain, it allows you to store an ipfs hash under the namespace of your peer_id.
Does this mean that each ipfs node can only maintain one ipns hash?
Also, in the documentation on ipfs.io explaining how ipns works, it contains the following line:
Note that updating an ipns entry can "break links" because anything referencing an ipns
entry might no longer point to the content it expected. There is no way around this
( you know, mutability ), therefore, ipns links should be used carefully
if you want to ensure permanence.
What does it mean here by 'break links'?
Each ipfs node can have an arbitrary number of IPNS keypairs.
You have a default keypair, which gets generated on node creation. You publish to this if you do ipfs name publish <somehash>
.
$ ipfs name publish /ipfs/QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
Published to QmPgJooiXNDGWE6QGWhks935n8DiTP7ysH8wezAbkCrND7: /ipfs/QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
This keypair is also the one used for the node id.
$ ipfs id --format='<id>'
QmPgJooiXNDGWE6QGWhks935n8DiTP7ysH8wezAbkCrND7
But you can generate any number of additional keys, like this:
$ ipfs key gen -t rsa -s 2048 test
QmfMtYnxBH46HKE89NKTfffSckiSw3c9UD1n3rdyC5zphM
And then publish to those named keys
$ ipfs name publish --key=test
/ipfs/QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
Published to QmfMtYnxBH46HKE89NKTfffSckiSw3c9UD1n3rdyC5zphM: /ipfs/QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
It is probably worth noting that these keypairs can be copied to other nodes. Any node who is in possession of a keypair (including the private key) can publish to that name.
Now, about the breaking of links. The value for an IPNS name might change over time. That's the whole point of it. So while an ipfs link like /ipfs/Qm1234/foo/bar/index.html
can never go stale as long as the content is still somewhere on the network, a link like /ipns/Qm5678/foo/bar/index.html
can exist at some time and then cease to exist as soon as a new, different directory structure is published under that name.