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

Introduce builders for each of CID versions #52

Open
Mingela opened this issue Dec 30, 2019 · 1 comment
Open

Introduce builders for each of CID versions #52

Mingela opened this issue Dec 30, 2019 · 1 comment

Comments

@Mingela
Copy link

Mingela commented Dec 30, 2019

Now there is a CID V0 used by default in CidBuilders. But why not to use V1 one?

go-merkledag/node.go

Lines 66 to 83 in d532cda

// CidBuilder returns the CID Builder for this ProtoNode, it is never nil
func (n *ProtoNode) CidBuilder() cid.Builder {
if n.builder == nil {
n.builder = v0CidPrefix
}
return n.builder
}
// SetCidBuilder sets the CID builder if it is non nil, if nil then it
// is reset to the default value
func (n *ProtoNode) SetCidBuilder(builder cid.Builder) {
if builder == nil {
n.builder = v0CidPrefix
} else {
n.builder = builder.WithCodec(cid.DagProtobuf)
n.cached = cid.Undef
}
}

And probably a client do not even guess what's going inside there methods. How about switching to an interface providing builders for each version etc?

@Stebalien
Copy link
Member

We still use CIDv0 by default for dag-pb to avoid changing the hashes.

And probably a client do not even guess what's going inside there methods. How about switching to an interface providing builders for each version etc?

I'm not sure what you're asking. You can switch to a CIDv1 builder by calling n.SetCidBuilder(&cid.V1Builder{Codec: cid.DatProtobuf, mh.SHA2_256, MhLength: -1}).

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

No branches or pull requests

2 participants