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
80c1eb3e
Commit
80c1eb3e
authored
Sep 05, 2018
by
Kejie Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add copy dagservice function
parent
6b9f5037
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
daghelpers.go
daghelpers.go
+20
-0
No files found.
daghelpers.go
View file @
80c1eb3e
...
...
@@ -89,6 +89,26 @@ func GetNodes(ctx context.Context, ds NodeGetter, keys []*cid.Cid) []*NodePromis
return
promises
}
func
Copy
(
ctx
context
.
Context
,
from
,
to
DAGService
,
root
*
cid
.
Cid
)
error
{
node
,
err
:=
from
.
Get
(
ctx
,
root
)
if
err
!=
nil
{
return
err
}
links
:=
node
.
Links
()
if
len
(
links
)
==
0
{
n
:=
node
.
Copy
()
to
.
Add
(
ctx
,
n
)
return
nil
}
for
_
,
link
:=
range
links
{
err
:=
Copy
(
ctx
,
from
,
to
,
link
.
Cid
)
if
err
!=
nil
{
return
err
}
}
return
nil
}
// Remove duplicates from a list of keys
func
dedupeKeys
(
cids
[]
*
cid
.
Cid
)
[]
*
cid
.
Cid
{
set
:=
cid
.
NewSet
()
...
...
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