Commit 8f57b7b8 authored by Jeromy's avatar Jeromy

implement dagmodifier and tests.

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