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
2b4aa1a3
Commit
2b4aa1a3
authored
Apr 19, 2018
by
Hector Sanjuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix json
License: MIT Signed-off-by:
Hector Sanjuan
<
hector@protocol.ai
>
parent
49051a39
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
23 deletions
+10
-23
merkledag_test.go
merkledag_test.go
+7
-7
node.go
node.go
+0
-13
utils/utils.go
utils/utils.go
+3
-3
No files found.
merkledag_test.go
View file @
2b4aa1a3
...
...
@@ -340,7 +340,7 @@ func TestFetchFailure(t *testing.T) {
t
.
Fatal
(
err
)
}
err
=
top
.
AddNodeLink
Clean
(
fmt
.
Sprintf
(
"AA%d"
,
i
),
nd
)
err
=
top
.
AddNodeLink
(
fmt
.
Sprintf
(
"AA%d"
,
i
),
nd
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -353,7 +353,7 @@ func TestFetchFailure(t *testing.T) {
t
.
Fatal
(
err
)
}
err
=
top
.
AddNodeLink
Clean
(
fmt
.
Sprintf
(
"BB%d"
,
i
),
nd
)
err
=
top
.
AddNodeLink
(
fmt
.
Sprintf
(
"BB%d"
,
i
),
nd
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -597,19 +597,19 @@ func TestEnumerateAsyncFailsNotFound(t *testing.T) {
}
parent
:=
new
(
ProtoNode
)
if
err
:=
parent
.
AddNodeLink
Clean
(
"a"
,
a
);
err
!=
nil
{
if
err
:=
parent
.
AddNodeLink
(
"a"
,
a
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
parent
.
AddNodeLink
Clean
(
"b"
,
b
);
err
!=
nil
{
if
err
:=
parent
.
AddNodeLink
(
"b"
,
b
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
parent
.
AddNodeLink
Clean
(
"c"
,
c
);
err
!=
nil
{
if
err
:=
parent
.
AddNodeLink
(
"c"
,
c
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
parent
.
AddNodeLink
Clean
(
"d"
,
d
);
err
!=
nil
{
if
err
:=
parent
.
AddNodeLink
(
"d"
,
d
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -696,7 +696,7 @@ func mkNodeWithChildren(getChild func() *ProtoNode, width int) *ProtoNode {
for
i
:=
0
;
i
<
width
;
i
++
{
c
:=
getChild
()
if
err
:=
cur
.
AddNodeLink
Clean
(
fmt
.
Sprint
(
i
),
c
);
err
!=
nil
{
if
err
:=
cur
.
AddNodeLink
(
fmt
.
Sprint
(
i
),
c
);
err
!=
nil
{
panic
(
err
)
}
}
...
...
node.go
View file @
2b4aa1a3
...
...
@@ -104,19 +104,6 @@ func (n *ProtoNode) AddNodeLink(name string, that ipld.Node) error {
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
func
(
n
*
ProtoNode
)
AddRawLink
(
name
string
,
l
*
ipld
.
Link
)
error
{
n
.
encoded
=
nil
...
...
utils/utils.go
View file @
2b4aa1a3
...
...
@@ -75,7 +75,7 @@ func addLink(ctx context.Context, ds ipld.DAGService, root *dag.ProtoNode, child
// ensure no link with that name already exists
_
=
root
.
RemoveNodeLink
(
childname
)
// ignore error, only option is ErrNotFound
if
err
:=
root
.
AddNodeLink
Clean
(
childname
,
childnd
);
err
!=
nil
{
if
err
:=
root
.
AddNodeLink
(
childname
,
childnd
);
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -127,7 +127,7 @@ func (e *Editor) insertNodeAtPath(ctx context.Context, root *dag.ProtoNode, path
_
=
e
.
tmp
.
Remove
(
ctx
,
root
.
Cid
())
_
=
root
.
RemoveNodeLink
(
path
[
0
])
err
=
root
.
AddNodeLink
Clean
(
path
[
0
],
ndprime
)
err
=
root
.
AddNodeLink
(
path
[
0
],
ndprime
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -186,7 +186,7 @@ func (e *Editor) rmLink(ctx context.Context, root *dag.ProtoNode, path []string)
e
.
tmp
.
Remove
(
ctx
,
root
.
Cid
())
_
=
root
.
RemoveNodeLink
(
path
[
0
])
err
=
root
.
AddNodeLink
Clean
(
path
[
0
],
nnode
)
err
=
root
.
AddNodeLink
(
path
[
0
],
nnode
)
if
err
!=
nil
{
return
nil
,
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