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
07869d6a
Commit
07869d6a
authored
Aug 17, 2017
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move GetLinks to daghelpers
Keep merkledag clean.
parent
f2fc6cec
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
17 deletions
+17
-17
daghelpers.go
daghelpers.go
+17
-0
merkledag.go
merkledag.go
+0
-17
No files found.
daghelpers.go
View file @
07869d6a
...
...
@@ -6,6 +6,23 @@ import (
cid
"github.com/ipfs/go-cid"
)
// GetLinks returns the CIDs of the children of the given node. Prefer this
// method over looking up the node itself and calling `Links()` on it as this
// method may be able to use a link cache.
func
GetLinks
(
ctx
context
.
Context
,
ng
NodeGetter
,
c
*
cid
.
Cid
)
([]
*
Link
,
error
)
{
if
c
.
Type
()
==
cid
.
Raw
{
return
nil
,
nil
}
if
gl
,
ok
:=
ng
.
(
LinkGetter
);
ok
{
return
gl
.
GetLinks
(
ctx
,
c
)
}
node
,
err
:=
ng
.
Get
(
ctx
,
c
)
if
err
!=
nil
{
return
nil
,
err
}
return
node
.
Links
(),
nil
}
// GetDAG will fill out all of the links of the given Node.
// It returns an array of NodePromise with the linked nodes all in the proper
// order.
...
...
merkledag.go
View file @
07869d6a
...
...
@@ -44,23 +44,6 @@ type LinkGetter interface {
GetLinks
(
ctx
context
.
Context
,
nd
*
cid
.
Cid
)
([]
*
Link
,
error
)
}
// GetLinks returns the CIDs of the children of the given node. Prefer this
// method over looking up the node itself and calling `Links()` on it as this
// method may be able to use a link cache.
func
GetLinks
(
ctx
context
.
Context
,
ng
NodeGetter
,
c
*
cid
.
Cid
)
([]
*
Link
,
error
)
{
if
c
.
Type
()
==
cid
.
Raw
{
return
nil
,
nil
}
if
gl
,
ok
:=
ng
.
(
LinkGetter
);
ok
{
return
gl
.
GetLinks
(
ctx
,
c
)
}
node
,
err
:=
ng
.
Get
(
ctx
,
c
)
if
err
!=
nil
{
return
nil
,
err
}
return
node
.
Links
(),
nil
}
// DAGService is an IPFS Merkle DAG service.
type
DAGService
interface
{
NodeGetter
...
...
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