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
ec392edf
Commit
ec392edf
authored
Feb 21, 2017
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some documentation on the intended purpose of GetLinks.
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
parent
26f7ee2f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
merkledag.go
merkledag.go
+9
-4
No files found.
merkledag.go
View file @
ec392edf
...
@@ -36,8 +36,10 @@ type DAGService interface {
...
@@ -36,8 +36,10 @@ type DAGService interface {
}
}
type
LinkService
interface
{
type
LinkService
interface
{
// Return all links for a node, may be more effect than
// GetLinks return all links for a node. The complete node does not
// calling Get in DAGService
// necessarily have to exist locally, or at all. For example, raw
// leaves cannot possibly have links so there is no need to look
// at the node.
GetLinks
(
context
.
Context
,
*
cid
.
Cid
)
([]
*
node
.
Link
,
error
)
GetLinks
(
context
.
Context
,
*
cid
.
Cid
)
([]
*
node
.
Link
,
error
)
GetOfflineLinkService
()
LinkService
GetOfflineLinkService
()
LinkService
...
@@ -114,6 +116,8 @@ func decodeBlock(b blocks.Block) (node.Node, error) {
...
@@ -114,6 +116,8 @@ func decodeBlock(b blocks.Block) (node.Node, error) {
}
}
}
}
// GetLinks return the links for the node, the node doesn't necessarily have
// to exist locally.
func
(
n
*
dagService
)
GetLinks
(
ctx
context
.
Context
,
c
*
cid
.
Cid
)
([]
*
node
.
Link
,
error
)
{
func
(
n
*
dagService
)
GetLinks
(
ctx
context
.
Context
,
c
*
cid
.
Cid
)
([]
*
node
.
Link
,
error
)
{
if
c
.
Type
()
==
cid
.
Raw
{
if
c
.
Type
()
==
cid
.
Raw
{
return
nil
,
nil
return
nil
,
nil
...
@@ -138,8 +142,9 @@ func (n *dagService) Remove(nd node.Node) error {
...
@@ -138,8 +142,9 @@ func (n *dagService) Remove(nd node.Node) error {
return
n
.
Blocks
.
DeleteBlock
(
nd
)
return
n
.
Blocks
.
DeleteBlock
(
nd
)
}
}
// get the links for a node, from the node, bypassing the
// GetLinksDirect creates a function to get the links for a node, from
// LinkService
// the node, bypassing the LinkService. If the node does not exist
// locally (and can not be retrieved) an error will be returned.
func
GetLinksDirect
(
serv
DAGService
)
GetLinks
{
func
GetLinksDirect
(
serv
DAGService
)
GetLinks
{
return
func
(
ctx
context
.
Context
,
c
*
cid
.
Cid
)
([]
*
node
.
Link
,
error
)
{
return
func
(
ctx
context
.
Context
,
c
*
cid
.
Cid
)
([]
*
node
.
Link
,
error
)
{
node
,
err
:=
serv
.
Get
(
ctx
,
c
)
node
,
err
:=
serv
.
Get
(
ctx
,
c
)
...
...
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