ipfs-shipyard / ipfsx

Experimental IPFS API
MIT License
17 stars 5 forks source link

RFC dag.resolve #9

Closed alanshaw closed 6 years ago

alanshaw commented 6 years ago

When given input path /ipfs/QmRoot/path/to/data, return { cid, path }.

Where cid is the CID of the node that contains the data addressed by the input path. path in the result is the path within the node to the data.

Examples:

multi node:

dag.put({ to: { data: 5 } }, { format: 'dag-cbor' }) // QmLeaf
dag.put({ path: new CID('QmLeaf') }, { format: 'dag-cbor' }) // QmRoot

dag.resolve('/ipfs/QmRoot/path/to/data') would return:

{ cid: CID<QmLeaf>, path: 'to/data' }

single node:

dag.put({ path: { to: { data: 5 } } }, { format: 'dag-cbor' }) // QmRoot

dag.resolve('/ipfs/QmRoot/path/to/data') would return:

{ cid: CID<QmRoot>, path: 'path/to/data' }