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
20f0643a
Commit
20f0643a
authored
Oct 07, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed error from return type of blocks.NewBlock()
parent
8f57b7b8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
coding.go
coding.go
+3
-0
merkledag.go
merkledag.go
+7
-3
No files found.
coding.go
View file @
20f0643a
...
...
@@ -3,6 +3,8 @@ package merkledag
import
(
"fmt"
u
"github.com/jbenet/go-ipfs/util"
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
)
...
...
@@ -76,6 +78,7 @@ func (n *Node) Encoded(force bool) ([]byte, error) {
if
err
!=
nil
{
return
[]
byte
{},
err
}
n
.
cached
=
u
.
Hash
(
n
.
encoded
)
}
return
n
.
encoded
,
nil
...
...
merkledag.go
View file @
20f0643a
...
...
@@ -24,6 +24,8 @@ type Node struct {
// cache encoded/marshaled value
encoded
[]
byte
cached
mh
.
Multihash
}
// Link represents an IPFS Merkle DAG Link between Nodes.
...
...
@@ -122,12 +124,12 @@ func (n *Node) Size() (uint64, error) {
// Multihash hashes the encoded data of this node.
func
(
n
*
Node
)
Multihash
()
(
mh
.
Multihash
,
error
)
{
b
,
err
:=
n
.
Encoded
(
false
)
_
,
err
:=
n
.
Encoded
(
false
)
if
err
!=
nil
{
return
nil
,
err
}
return
u
.
Hash
(
b
)
,
nil
return
n
.
cached
,
nil
}
// Key returns the Multihash as a key, for maps.
...
...
@@ -183,7 +185,9 @@ func (n *DAGService) Add(nd *Node) (u.Key, error) {
return
""
,
err
}
b
,
err
:=
blocks
.
NewBlock
(
d
)
b
:=
new
(
blocks
.
Block
)
b
.
Data
=
d
b
.
Multihash
,
err
=
nd
.
Multihash
()
if
err
!=
nil
{
return
""
,
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