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

Update to use new Builder interface for creating CIDs. #6

Merged
merged 2 commits into from
Aug 11, 2018

Conversation

kevina
Copy link
Contributor

@kevina kevina commented Aug 10, 2018

Depends on ipfs/go-cid#53.

node.go Outdated
@@ -63,14 +63,21 @@ func PrefixForCidVersion(version int) (cid.Prefix, error) {
}
}

// Prefix returns the CID Prefix for this ProtoNode, it is never nil
func (n *ProtoNode) Prefix() cid.Builder {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to break this anyways, we might as well call this CidBuilder and SetCidBuilder. Any reason not to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I think I will just use Builder though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM.

raw.go Outdated
if prefix.Version == 0 {
prefix.Version = 1
}
func NewRawNodeWPrefix(data []byte, prefix cid.Builder) (*RawNode, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same. This is a breaking change (non-pointer Prefix doesn't implement cid.Builder, I think).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-pointer Prefix doesn't implement cid.Builder

Actually it does.

c, err := prefix.Sum(data)
// NewRawNodeWPrefix creates a RawNode using the provided cid builder
func NewRawNodeWPrefix(data []byte, builder cid.Builder) (*RawNode, error) {
builder = builder.WithCodec(cid.Raw)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: leaving this one alone for now. I personally think we should change NewRawNode to always take a builder rather than creating a separate function, it can take nil if the user wishes to use the default.

@kevina kevina merged commit 0244e50 into master Aug 11, 2018
@ghost ghost removed the status/in-progress In progress label Aug 11, 2018
@kevina kevina deleted the kevina/builder branch August 11, 2018 03:11
Jorropo pushed a commit to ipfs/boxo that referenced this pull request Mar 15, 2023
Update to use new Builder interface for creating CIDs.

This commit was moved from ipfs/go-merkledag@0244e50
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

Successfully merging this pull request may close these issues.

2 participants