Commit 20f0643a authored by Jeromy's avatar Jeromy

removed error from return type of blocks.NewBlock()

parent 8f57b7b8
......@@ -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
......
......@@ -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
}
......
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