Commit 70cb3dd8 authored by Kevin Atkinson's avatar Kevin Atkinson

Rename Prefix() and SetPrefix() to CidPrefix() and SetCidPrefix().

parent ff4fe8a1
...@@ -93,7 +93,7 @@ func (n *ProtoNode) EncodeProtobuf(force bool) ([]byte, error) { ...@@ -93,7 +93,7 @@ func (n *ProtoNode) EncodeProtobuf(force bool) ([]byte, error) {
} }
if n.cached == nil { if n.cached == nil {
c, err := n.Prefix().Sum(n.encoded) c, err := n.CidBuilder().Sum(n.encoded)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -131,7 +131,7 @@ func DecodeProtobufBlock(b blocks.Block) (ipld.Node, error) { ...@@ -131,7 +131,7 @@ func DecodeProtobufBlock(b blocks.Block) (ipld.Node, error) {
} }
decnd.cached = c decnd.cached = c
decnd.SetPrefix(c.Prefix()) decnd.SetCidBuilder(c.Prefix())
return decnd, nil return decnd, nil
} }
......
...@@ -63,21 +63,21 @@ func PrefixForCidVersion(version int) (cid.Prefix, error) { ...@@ -63,21 +63,21 @@ func PrefixForCidVersion(version int) (cid.Prefix, error) {
} }
} }
// Prefix returns the CID Prefix for this ProtoNode, it is never nil // CidBuilder returns the CID Builder for this ProtoNode, it is never nil
func (n *ProtoNode) Prefix() cid.Builder { func (n *ProtoNode) CidBuilder() cid.Builder {
if n.builder == nil { if n.builder == nil {
n.builder = v0CidPrefix n.builder = v0CidPrefix
} }
return n.builder return n.builder
} }
// SetPrefix sets the CID prefix if it is non nil, if prefix is nil then // SetCidBuilder sets the CID builder if it is non nil, if nil then it
// it resets it the default value // is reset to the default value
func (n *ProtoNode) SetPrefix(prefix cid.Builder) { func (n *ProtoNode) SetCidBuilder(builder cid.Builder) {
if prefix == nil { if builder == nil {
n.builder = v0CidPrefix n.builder = v0CidPrefix
} else { } else {
n.builder = prefix.WithCodec(cid.DagProtobuf) n.builder = builder.WithCodec(cid.DagProtobuf)
n.encoded = nil n.encoded = nil
n.cached = nil n.cached = nil
} }
......
...@@ -34,11 +34,10 @@ func DecodeRawBlock(block blocks.Block) (ipld.Node, error) { ...@@ -34,11 +34,10 @@ func DecodeRawBlock(block blocks.Block) (ipld.Node, error) {
var _ ipld.DecodeBlockFunc = DecodeRawBlock var _ ipld.DecodeBlockFunc = DecodeRawBlock
// NewRawNodeWPrefix creates a RawNode with the hash function // NewRawNodeWPrefix creates a RawNode using the provided cid builder
// specified in prefix. func NewRawNodeWPrefix(data []byte, builder cid.Builder) (*RawNode, error) {
func NewRawNodeWPrefix(data []byte, prefix cid.Builder) (*RawNode, error) { builder = builder.WithCodec(cid.Raw)
prefix = prefix.WithCodec(cid.Raw) c, err := builder.Sum(data)
c, err := prefix.Sum(data)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment