Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Support CIDs in dag-pb links #79

Closed
olizilla opened this issue Jul 31, 2018 · 2 comments
Closed

Support CIDs in dag-pb links #79

olizilla opened this issue Jul 31, 2018 · 2 comments
Assignees

Comments

@olizilla
Copy link
Member

js-ipld-dag-pb assumes that links will be multihashes

class DAGLink {
constructor (name, size, multihash) {
assert(multihash, 'A link requires a multihash to point to')
// assert(size, 'A link requires a size')
// note - links should include size, but this assert is disabled
// for now to maintain consistency with go-ipfs pinset
this._name = name || ''
this._size = size
if (typeof multihash === 'string') {
this._multihash = mh.fromB58String(multihash)
} else if (Buffer.isBuffer(multihash)) {
this._multihash = multihash
}
}

Here is a dag-pb node where one of the links is a CIDv1
https://ipfs.io/api/v0/dag/get?arg=QmViWi5az9iiPzESM6ruHf84TcmHSAVQ2KQdNveoDH7eaY/refs/heads

// 20180731162407
// https://ipfs.io/api/v0/dag/get?arg=QmViWi5az9iiPzESM6ruHf84TcmHSAVQ2KQdNveoDH7eaY/refs/heads

{
  "data": "CAE=",
  "links": [
    {
      "Name": "archive",
      "Size": 83,
      "Cid": {
        "/": "QmfBgo8BAB26hFtyGNGK46rqYkKLFvWYfTqjrGdbUEjnUU"
      }
    },
    {
      "Name": "master",
      "Size": 42,
      "Cid": {
        "/": "z8mWaJHXieAVxxLagBpdaNWFEBKVWmMiE"
      }
    }
  ]
}

I assume we need to upgrade DagLink to support CIDs, but I've never seen one like that before, so I first want to verify that such a thing should be possible.

@vmx
Copy link
Member

vmx commented Jul 31, 2018

@diasdavid, @Stebalien Can you help?

@Stebalien
Copy link

Yes, they can be CIDv1 links. Specifically, unixfs can store CIDv1 pointers to raw blocks. That's how we implement the raw leaves feature (where we store file chunks as raw data instead of wrapping them in protobufs).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants