-
Notifications
You must be signed in to change notification settings - Fork 38
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
Conversation
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
Update to use new Builder interface for creating CIDs. This commit was moved from ipfs/go-merkledag@0244e50
Depends on ipfs/go-cid#53.