IPNS and CID changed

Hello,

I need some more information about what happen exactly when a CID is changed with IPNS ?
I understand that the name is the hashed public key of the peer that add the content, but if i need to update this content what happen under the hood ?

I have some questions:
→ is IPNS points directly to the new CID generated ? (i.e can you explain the process behind this new pointers that points to the new CIDs)
→ What happen with the last CIDs, the GC delete it if he wasn’t pinned ?

1 Like

an IPNS is a key:value mapping in the DHT where:

  • key: hash of a public key
  • value the following record type
message IpnsEntry {
	enum ValidityType {
		// setting an EOL says "this record is valid until..."
		EOL = 0;
	}
	required bytes value = 1; // this is where the CID (or DNSLink path) is stored
	required bytes signature = 2;

	optional ValidityType validityType = 3;
	optional bytes validity = 4;

	optional uint64 sequence = 5;

	optional uint64 ttl = 6;

	optional bytes pubKey = 7;
}

(from https://github.com/ipfs/specs/blob/main/IPNS.md)

but if i need to update this content what happen under the hood ?

A new record is created with the sequence number incremented. Any node that has an older record will drop it in favour of the one with the higher sequence number.

→ What happen with the last CIDs, the GC delete it if he wasn’t pinned ?

The IPNS record is just a pointer. The CIDs and whether they are pinned is independent from the IPNS record.
GC in one IPFS node will delete any CID it isn’t pinning even if there are IPNS records.
In other words, it’s your responsibility to ensure that the CIDs you are pointing in the IPNS record are pinned and available to the network.

Hope that helps

2 Likes

Thank you, this help me a lot !

2 Likes