Commit e02443c3 authored by Mildred Ki'Lya's avatar Mildred Ki'Lya

Rename Encoded() to EncodeProtobuf()

License: MIT
Signed-off-by: default avatarMildred Ki'Lya <mildred-pub.git@mildred.fr>
parent 00d312ea
...@@ -68,9 +68,9 @@ func (n *Node) getPBNode() *pb.PBNode { ...@@ -68,9 +68,9 @@ func (n *Node) getPBNode() *pb.PBNode {
return pbn return pbn
} }
// Encoded returns the encoded raw data version of a Node instance. // EncodeProtobuf returns the encoded raw data version of a Node instance.
// It may use a cached encoded version, unless the force flag is given. // It may use a cached encoded version, unless the force flag is given.
func (n *Node) Encoded(force bool) ([]byte, error) { func (n *Node) EncodeProtobuf(force bool) ([]byte, error) {
sort.Stable(LinkSlice(n.Links)) // keep links sorted sort.Stable(LinkSlice(n.Links)) // keep links sorted
if n.encoded == nil || force { if n.encoded == nil || force {
var err error var err error
......
...@@ -49,7 +49,7 @@ func (n *dagService) Add(nd *Node) (key.Key, error) { ...@@ -49,7 +49,7 @@ func (n *dagService) Add(nd *Node) (key.Key, error) {
return "", fmt.Errorf("dagService is nil") return "", fmt.Errorf("dagService is nil")
} }
d, err := nd.Encoded(false) d, err := nd.EncodeProtobuf(false)
if err != nil { if err != nil {
return "", err return "", err
} }
...@@ -313,7 +313,7 @@ type Batch struct { ...@@ -313,7 +313,7 @@ type Batch struct {
} }
func (t *Batch) Add(nd *Node) (key.Key, error) { func (t *Batch) Add(nd *Node) (key.Key, error) {
d, err := nd.Encoded(false) d, err := nd.EncodeProtobuf(false)
if err != nil { if err != nil {
return "", err return "", err
} }
......
...@@ -64,7 +64,7 @@ func TestNode(t *testing.T) { ...@@ -64,7 +64,7 @@ func TestNode(t *testing.T) {
fmt.Println("-", l.Name, l.Size, l.Hash) fmt.Println("-", l.Name, l.Size, l.Hash)
} }
e, err := n.Encoded(false) e, err := n.EncodeProtobuf(false)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} else { } else {
...@@ -96,9 +96,9 @@ func TestNode(t *testing.T) { ...@@ -96,9 +96,9 @@ func TestNode(t *testing.T) {
} }
func SubtestNodeStat(t *testing.T, n *Node) { func SubtestNodeStat(t *testing.T, n *Node) {
enc, err := n.Encoded(true) enc, err := n.EncodeProtobuf(true)
if err != nil { if err != nil {
t.Error("n.Encoded(true) failed") t.Error("n.EncodeProtobuf(true) failed")
return return
} }
......
...@@ -203,7 +203,7 @@ func (n *Node) UpdateNodeLink(name string, that *Node) (*Node, error) { ...@@ -203,7 +203,7 @@ func (n *Node) UpdateNodeLink(name string, that *Node) (*Node, error) {
// Size returns the total size of the data addressed by node, // Size returns the total size of the data addressed by node,
// including the total sizes of references. // including the total sizes of references.
func (n *Node) Size() (uint64, error) { func (n *Node) Size() (uint64, error) {
b, err := n.Encoded(false) b, err := n.EncodeProtobuf(false)
if err != nil { if err != nil {
return 0, err return 0, err
} }
...@@ -217,7 +217,7 @@ func (n *Node) Size() (uint64, error) { ...@@ -217,7 +217,7 @@ func (n *Node) Size() (uint64, error) {
// Stat returns statistics on the node. // Stat returns statistics on the node.
func (n *Node) Stat() (*NodeStat, error) { func (n *Node) Stat() (*NodeStat, error) {
enc, err := n.Encoded(false) enc, err := n.EncodeProtobuf(false)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -244,8 +244,8 @@ func (n *Node) Stat() (*NodeStat, error) { ...@@ -244,8 +244,8 @@ func (n *Node) Stat() (*NodeStat, error) {
// Multihash hashes the encoded data of this node. // Multihash hashes the encoded data of this node.
func (n *Node) Multihash() (mh.Multihash, error) { func (n *Node) Multihash() (mh.Multihash, error) {
// Note: Encoded generates the hash and puts it in n.cached. // Note: EncodeProtobuf generates the hash and puts it in n.cached.
_, err := n.Encoded(false) _, err := n.EncodeProtobuf(false)
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