Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codecs for IPFS Cluster #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add codecs for IPFS Cluster #118

wants to merge 1 commit into from

Conversation

hsanjuan
Copy link
Contributor

@hsanjuan hsanjuan commented Feb 6, 2019

It would be useful for Cluster to have our own block codes so that
we can identify ownership of blocks from their CIDs.

cc. @lanzafame

It would be useful for Cluster to have our own block codes so that
we can identify ownership of blocks from their CIDs.
@hsanjuan hsanjuan self-assigned this Feb 6, 2019
@ghost ghost added the in progress label Feb 6, 2019
@Stebalien
Copy link
Member

Are these IPLD codecs?

@hsanjuan
Copy link
Contributor Author

hsanjuan commented Feb 6, 2019

@Stebalien if you mean that CIDs with these codecs will refer to blocks that decode to ipld.Node, yes.

@Stebalien
Copy link
Member

As in, will you be registering a new IPLD format?

@hsanjuan hsanjuan changed the title Add codecs for IPFS Cluster [DNM] Add codecs for IPFS Cluster Feb 7, 2019
@hsanjuan hsanjuan changed the title [DNM] Add codecs for IPFS Cluster Add codecs for IPFS Cluster Feb 7, 2019
@hsanjuan
Copy link
Contributor Author

hsanjuan commented Feb 7, 2019

@Stebalien not yet. Right now, we're going to use existing cbor and protobuf and this would just work as aliases. But we might replace them in the future.

Also, @lanzafame thought that being able to decide if a block in the ipfs datastore belongs to IPFS cluster (by using our own codecs) might be very useful when doing disaster recovery.

Is it a problem to reserve codecs like this and we should stick to dag-cbor and dag-pb? (we could also use custom ones "unofficially" but that's not so polite).

@Stebalien
Copy link
Member

So, "codec" part of a CID isn't really supposed to be used as a "type" in this way. It's supposed to tell you how to interpret the target data as a structured IPLD object, not how to interpret the resulting IPLD object. They exist for interoperability with existing systems and to allow us to introduce new serialization formats with new features.

The drawback to adding new codecs like this is that everyone will need to completely understand that new codec to do anything useful with the data (e.g., follow a link). Let's say you're building a webapp and add a custom IPLD format + codec. Now you ask go-ipfs to resolve /ipld/CID_WITH_CUSTOM_CODEC/path/to/data. go-ipfs will need to support your app's custom format, even if you're really just using DagCBOR under the hood.

@hsanjuan
Copy link
Contributor Author

The drawback to adding new codecs like this is that everyone will need to completely understand that new codec to do anything useful with the data (e.g., follow a link). Let's say you're building a webapp and add a custom IPLD format + codec. Now you ask go-ipfs to resolve /ipld/CID_WITH_CUSTOM_CODEC/path/to/data. go-ipfs will need to support your app's custom format, even if you're really just using DagCBOR under the hood.

I fully understand your point. For the sake of the argument, normally the node's data is opaque anyway, so the only useful thing for go-ipfs is Cid() and Link-related operations (ipld.Node). In the case of other apps, they still need to manually register the cbor or the protobuf codec along with the right decoder to work with these formats. In that light, It does not seem completely out of place to register the cluster codecbytes+decoder to understand nodes created by cluster for cluster, even if the underlying format happens to be dag-pb.

That said, it is in our interest that go-ipfs understands our blocks and I don't think my arguments are strong enough to support adding our aliases to go-ipfs codebase for what is already a supported format in the end.

Would reserving codecs for future use (in case we do create our own formats) be ok (I'd rename accordingly)? Or would you rather let this sit until that moment happens?

@Stebalien
Copy link
Member

Could you create a special reference type? Something like:

type ClusterRef struct {
  Cid cid.Cid
  Type string
}

Honestly, this is the "right" way to do this from IPLD's standpoint.

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

Successfully merging this pull request may close these issues.

None yet

2 participants