Commit 8f57b7b8 authored by Jeromy's avatar Jeromy

implement dagmodifier and tests.

parent ccae0acd
......@@ -34,9 +34,6 @@ type Link struct {
// cumulative size of target object
Size uint64
// cumulative size of data stored in object
DataSize uint64
// multihash of the target object
Hash mh.Multihash
......@@ -44,45 +41,45 @@ type Link struct {
Node *Node
}
// AddNodeLink adds a link to another node.
func (n *Node) AddNodeLink(name string, that *Node) error {
s, err := that.Size()
func MakeLink(n *Node) (*Link, error) {
s, err := n.Size()
if err != nil {
return err
return nil, err
}
h, err := that.Multihash()
h, err := n.Multihash()
if err != nil {
return err
return nil, err
}
n.Links = append(n.Links, &Link{
Name: name,
return &Link{
Size: s,
Hash: h,
Node: that,
})
return nil
}, nil
}
// AddNodeLink adds a link to another node. without keeping a reference to
// the child node
func (n *Node) AddNodeLinkClean(name string, that *Node) error {
s, err := that.Size()
// AddNodeLink adds a link to another node.
func (n *Node) AddNodeLink(name string, that *Node) error {
lnk, err := MakeLink(that)
if err != nil {
return err
}
lnk.Name = name
lnk.Node = that
n.Links = append(n.Links, lnk)
return nil
}
h, err := that.Multihash()
// AddNodeLink adds a link to another node. without keeping a reference to
// the child node
func (n *Node) AddNodeLinkClean(name string, that *Node) error {
lnk, err := MakeLink(that)
if err != nil {
return err
}
lnk.Name = name
n.Links = append(n.Links, &Link{
Name: name,
Size: s,
Hash: h,
})
n.Links = append(n.Links, lnk)
return nil
}
......
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