Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-merkledag
Commits
e02443c3
Commit
e02443c3
authored
Feb 25, 2016
by
Mildred Ki'Lya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Encoded() to EncodeProtobuf()
License: MIT Signed-off-by:
Mildred Ki'Lya
<
mildred-pub.git@mildred.fr
>
parent
00d312ea
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
11 deletions
+11
-11
coding.go
coding.go
+2
-2
merkledag.go
merkledag.go
+2
-2
merkledag_test.go
merkledag_test.go
+3
-3
node.go
node.go
+4
-4
No files found.
coding.go
View file @
e02443c3
...
@@ -68,9 +68,9 @@ func (n *Node) getPBNode() *pb.PBNode {
...
@@ -68,9 +68,9 @@ func (n *Node) getPBNode() *pb.PBNode {
return
pbn
return
pbn
}
}
// Encode
d
returns the encoded raw data version of a Node instance.
// Encode
Protobuf
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
)
Encode
d
(
force
bool
)
([]
byte
,
error
)
{
func
(
n
*
Node
)
Encode
Protobuf
(
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
...
...
merkledag.go
View file @
e02443c3
...
@@ -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
.
Encode
d
(
false
)
d
,
err
:=
nd
.
Encode
Protobuf
(
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
.
Encode
d
(
false
)
d
,
err
:=
nd
.
Encode
Protobuf
(
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
...
merkledag_test.go
View file @
e02443c3
...
@@ -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
.
Encode
d
(
false
)
e
,
err
:=
n
.
Encode
Protobuf
(
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
.
Encode
d
(
true
)
enc
,
err
:=
n
.
Encode
Protobuf
(
true
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
(
"n.Encode
d
(true) failed"
)
t
.
Error
(
"n.Encode
Protobuf
(true) failed"
)
return
return
}
}
...
...
node.go
View file @
e02443c3
...
@@ -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
.
Encode
d
(
false
)
b
,
err
:=
n
.
Encode
Protobuf
(
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
.
Encode
d
(
false
)
enc
,
err
:=
n
.
Encode
Protobuf
(
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: Encode
d
generates the hash and puts it in n.cached.
// Note: Encode
Protobuf
generates the hash and puts it in n.cached.
_
,
err
:=
n
.
Encode
d
(
false
)
_
,
err
:=
n
.
Encode
Protobuf
(
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment