From daf983d630e909f334bd8e4a3951294141b78403 Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Fri, 17 Feb 2017 04:05:57 -0500 Subject: [PATCH] Add some documentation on the intended purpose of GetLinks. License: MIT Signed-off-by: Kevin Atkinson --- merkledag/merkledag.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/merkledag/merkledag.go b/merkledag/merkledag.go index 872a9c007be6..1a3f5f6b3a00 100644 --- a/merkledag/merkledag.go +++ b/merkledag/merkledag.go @@ -36,8 +36,10 @@ type DAGService interface { } type LinkService interface { - // Return all links for a node, may be more effect than - // calling Get in DAGService + // Return all links for a node. The complete node does not + // necessarily have to exist locally, or at all. For example, raw + // leaves can not possible have links so there is no need to look + // at the node. GetLinks(context.Context, *cid.Cid) ([]*node.Link, error) GetOfflineLinkService() LinkService @@ -114,6 +116,8 @@ func decodeBlock(b blocks.Block) (node.Node, error) { } } +// GetLinks return the links for the node, the node doesn't necessary +// have to exist locally. func (n *dagService) GetLinks(ctx context.Context, c *cid.Cid) ([]*node.Link, error) { if c.Type() == cid.Raw { return nil, nil @@ -138,8 +142,9 @@ func (n *dagService) Remove(nd node.Node) error { return n.Blocks.DeleteBlock(nd) } -// get the links for a node, from the node, bypassing the -// LinkService +// Create a functtion to get the links for a node, from the node, +// bypassing the LinkService. Granted to fetch the node and will +// return an error if the node can not be retrieved. func GetLinksDirect(serv DAGService) GetLinks { return func(ctx context.Context, c *cid.Cid) ([]*node.Link, error) { node, err := serv.Get(ctx, c)