Skip to content

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

Merged
kevina merged 2 commits intomasterfrom
kevina/builder
Aug 11, 2018
Merged

Update to use new Builder interface for creating CIDs.#6
kevina merged 2 commits intomasterfrom
kevina/builder

Conversation

@kevina
Copy link
Contributor

@kevina kevina commented Aug 10, 2018

Depends on ipfs/go-cid#53.

node.go Outdated
}

// 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