I have a couple of general questions about IPLD so I’ll just gather them here instead of making a ton of separate posts.
Can IPLD link to IPNS records? If yes it seems like there should be a way to limit ipfs dag export since you can’t know beforehand how far out it will go.
What formats does the ipfs dag put command take? The help output doesn’t say.
I’m a little confused about json and cbor. I thought that if you gave the command a json file it would be added as cbor but I see there is a dag-cbor but I’ve also seen references to deg-json. I’m wondering how dag-json would even work since, as far as I know, there isn’t a canonical json serialization that would lead to a byte identical serialization.
How does ipfs identify links in a document that you pass to ipfs dag put? Does it just look for values that look like CID’s. I’ve also seen a reference to them looking like objects like `{"/": “Qmfwqer93j23ijrweorjwko”}. I can’t seem to find much documentation on this subject.
No, at least I don’t think so (assuming you mean an IPLD object linking an IPNS hash that needs to be resolved). But re ipfs dag export, you cannot know how far it will go, you have to walk a DAG and the bottom is unknown.
The default --input-enc and --format flags are json and cbor. So yes. But you can also give it a binary protobuf and it will convert cbor just like it does between json and cbor (hopefully, I haven’t tried).
The very simplified idea is that IPLD nodes are just json-like objects and you can serialize them in arbitrary formats, be it json or cbor or protobuf. i.e. ipfs dag get spews out a json when you get a merkledag-protobuf node.
Yes, <cid>.toJSON() produces {"/": "<cid>"}, so that type of JSON-objects are parsed as IPLD “links” when deserializing JSON.
Thanks @hector. I’m really enjoying getting to know the nooks-and-crannies of IPFS and this is a big help.
One quick followup. The link serialization "/": "<cid>"} what is the interpretation of the key? Is it always a single slash or can it be something more complex?
Seems like a pain when you’ve got something else in there that also has a slash for a key but isn’t a link. You’d think something like “ipfs-cid-link” would be less dangerous and more informative. Oh well. Good to know. Thanks