Based on the return value of the dag get
operation in Kubo, a Merkle DAG node seems like it’s just an IPLD map with keys “Data” consisting of an application-specific payload and “Links” consisting of an array of links, following this protobuf.
Given this, I thought using Kubo’s dag put
operation would allow me to create a Merkle DAG node with my own payload instead of one with a Unixfs payload.
However, the node I create with dag put
behaves differently from the one that is created with files mkdir
and another operations that operate with unixfs. Below is the dag-json representation of one of the Unixfs nodes I have, which I got through dag get <cid>
after getting the CID from files stat /
.
{
"Data": {
"/": {
"bytes": "CAE"
}
},
"Links": [
{
"Hash": {
"/": "QmRQo6kz5QvqiBgXRMCasDzjDYqWfspnUoTZRRwW3ByHGj"
},
"Name": "test3.txt",
"Tsize": 22
},
{
"Hash": {
"/": "QmcJanXS6E7EXdFfwKcnHizRCzdutcf5oBVqQh57tvSXwv"
},
"Name": "test6.txt",
"Tsize": 22
}
]
}
Let CID1 be a CID for this node. When I run ipfs dag get CID1/Links
, I get an error stating that there is no such link named “Links”. However if I copy this dag-json and run it through dag put
to get CID2, and then run ipfs dag get CID2/Links
, I get the list of links returned. So it appears to me that there is a difference between the DAG nodes that Unixfs operations create over the ones that the dag
operations create.
Is someone able to explain this difference? How can I manually create my own Merkle DAG node with a custom “Data” payload that behaves more similarly to the ones that Unixfs creates?