Commit 2b4aa1a3 authored by Hector Sanjuan's avatar Hector Sanjuan

fix json

License: MIT
Signed-off-by: default avatarHector Sanjuan <hector@protocol.ai>
parent 49051a39
...@@ -340,7 +340,7 @@ func TestFetchFailure(t *testing.T) { ...@@ -340,7 +340,7 @@ func TestFetchFailure(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
err = top.AddNodeLinkClean(fmt.Sprintf("AA%d", i), nd) err = top.AddNodeLink(fmt.Sprintf("AA%d", i), nd)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
...@@ -353,7 +353,7 @@ func TestFetchFailure(t *testing.T) { ...@@ -353,7 +353,7 @@ func TestFetchFailure(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
err = top.AddNodeLinkClean(fmt.Sprintf("BB%d", i), nd) err = top.AddNodeLink(fmt.Sprintf("BB%d", i), nd)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
...@@ -597,19 +597,19 @@ func TestEnumerateAsyncFailsNotFound(t *testing.T) { ...@@ -597,19 +597,19 @@ func TestEnumerateAsyncFailsNotFound(t *testing.T) {
} }
parent := new(ProtoNode) parent := new(ProtoNode)
if err := parent.AddNodeLinkClean("a", a); err != nil { if err := parent.AddNodeLink("a", a); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if err := parent.AddNodeLinkClean("b", b); err != nil { if err := parent.AddNodeLink("b", b); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if err := parent.AddNodeLinkClean("c", c); err != nil { if err := parent.AddNodeLink("c", c); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if err := parent.AddNodeLinkClean("d", d); err != nil { if err := parent.AddNodeLink("d", d); err != nil {
t.Fatal(err) t.Fatal(err)
} }
...@@ -696,7 +696,7 @@ func mkNodeWithChildren(getChild func() *ProtoNode, width int) *ProtoNode { ...@@ -696,7 +696,7 @@ func mkNodeWithChildren(getChild func() *ProtoNode, width int) *ProtoNode {
for i := 0; i < width; i++ { for i := 0; i < width; i++ {
c := getChild() c := getChild()
if err := cur.AddNodeLinkClean(fmt.Sprint(i), c); err != nil { if err := cur.AddNodeLink(fmt.Sprint(i), c); err != nil {
panic(err) panic(err)
} }
} }
......
...@@ -104,19 +104,6 @@ func (n *ProtoNode) AddNodeLink(name string, that ipld.Node) error { ...@@ -104,19 +104,6 @@ func (n *ProtoNode) AddNodeLink(name string, that ipld.Node) error {
return nil return nil
} }
// AddNodeLinkClean adds a link to another node. without keeping a reference to
// the child node
func (n *ProtoNode) AddNodeLinkClean(name string, that ipld.Node) error {
n.encoded = nil
lnk, err := ipld.MakeLink(that)
if err != nil {
return err
}
n.AddRawLink(name, lnk)
return nil
}
// AddRawLink adds a copy of a link to this node // AddRawLink adds a copy of a link to this node
func (n *ProtoNode) AddRawLink(name string, l *ipld.Link) error { func (n *ProtoNode) AddRawLink(name string, l *ipld.Link) error {
n.encoded = nil n.encoded = nil
......
...@@ -75,7 +75,7 @@ func addLink(ctx context.Context, ds ipld.DAGService, root *dag.ProtoNode, child ...@@ -75,7 +75,7 @@ func addLink(ctx context.Context, ds ipld.DAGService, root *dag.ProtoNode, child
// ensure no link with that name already exists // ensure no link with that name already exists
_ = root.RemoveNodeLink(childname) // ignore error, only option is ErrNotFound _ = root.RemoveNodeLink(childname) // ignore error, only option is ErrNotFound
if err := root.AddNodeLinkClean(childname, childnd); err != nil { if err := root.AddNodeLink(childname, childnd); err != nil {
return nil, err return nil, err
} }
...@@ -127,7 +127,7 @@ func (e *Editor) insertNodeAtPath(ctx context.Context, root *dag.ProtoNode, path ...@@ -127,7 +127,7 @@ func (e *Editor) insertNodeAtPath(ctx context.Context, root *dag.ProtoNode, path
_ = e.tmp.Remove(ctx, root.Cid()) _ = e.tmp.Remove(ctx, root.Cid())
_ = root.RemoveNodeLink(path[0]) _ = root.RemoveNodeLink(path[0])
err = root.AddNodeLinkClean(path[0], ndprime) err = root.AddNodeLink(path[0], ndprime)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -186,7 +186,7 @@ func (e *Editor) rmLink(ctx context.Context, root *dag.ProtoNode, path []string) ...@@ -186,7 +186,7 @@ func (e *Editor) rmLink(ctx context.Context, root *dag.ProtoNode, path []string)
e.tmp.Remove(ctx, root.Cid()) e.tmp.Remove(ctx, root.Cid())
_ = root.RemoveNodeLink(path[0]) _ = root.RemoveNodeLink(path[0])
err = root.AddNodeLinkClean(path[0], nnode) err = root.AddNodeLink(path[0], nnode)
if err != nil { if err != nil {
return nil, err return nil, 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