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-ld-format
Commits
c793e51b
Commit
c793e51b
authored
Sep 06, 2018
by
Kejie Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drop external dep and update copy function
parent
a8cc0b99
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
18 deletions
+8
-18
daghelpers.go
daghelpers.go
+4
-11
daghelpers_test.go
daghelpers_test.go
+4
-7
No files found.
daghelpers.go
View file @
c793e51b
...
@@ -95,23 +95,16 @@ func Copy(ctx context.Context, from, to DAGService, root *cid.Cid) error {
...
@@ -95,23 +95,16 @@ func Copy(ctx context.Context, from, to DAGService, root *cid.Cid) error {
return
err
return
err
}
}
links
:=
node
.
Links
()
links
:=
node
.
Links
()
if
len
(
links
)
==
0
{
err
:=
to
.
Add
(
ctx
,
node
)
if
err
!=
nil
{
return
err
}
return
nil
}
for
_
,
link
:=
range
links
{
for
_
,
link
:=
range
links
{
err
:=
Copy
(
ctx
,
from
,
to
,
link
.
Cid
)
err
:=
Copy
(
ctx
,
from
,
to
,
link
.
Cid
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
}
err
=
to
.
Add
(
ctx
,
node
)
err
=
to
.
Add
(
ctx
,
node
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
}
return
nil
return
nil
}
}
...
...
daghelpers_test.go
View file @
c793e51b
...
@@ -4,7 +4,6 @@ import (
...
@@ -4,7 +4,6 @@ import (
"context"
"context"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-cid"
mh
"github.com/multiformats/go-multihash"
mh
"github.com/multiformats/go-multihash"
"github.com/stretchr/testify/assert"
"testing"
"testing"
)
)
...
@@ -132,13 +131,11 @@ func TestCopy(t *testing.T) {
...
@@ -132,13 +131,11 @@ func TestCopy(t *testing.T) {
}
}
r
,
err
:=
to
.
Get
(
ctx
,
root
.
Cid
())
r
,
err
:=
to
.
Get
(
ctx
,
root
.
Cid
())
if
err
!=
nil
{
if
err
!=
nil
||
len
(
r
.
Links
())
!=
2
{
t
.
Error
(
err
)
t
.
Error
(
"fail to copy dag"
)
}
}
l1
,
err
:=
to
.
Get
(
ctx
,
l11
.
Cid
())
l1
,
err
:=
to
.
Get
(
ctx
,
l11
.
Cid
())
if
err
!=
nil
{
if
err
!=
nil
||
len
(
l1
.
Links
())
!=
3
{
t
.
Error
(
err
)
t
.
Error
(
"fail to copy dag"
)
}
}
assert
.
Equal
(
t
,
len
(
r
.
Links
()),
2
)
assert
.
Equal
(
t
,
len
(
l1
.
Links
()),
3
)
}
}
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