Skip to content

Commit

Permalink
merkledag: optimize DagService GetLinks for Raw Nodes.
Browse files Browse the repository at this point in the history
A Raw Node can not possible have links, so there is no need to retrive
the node.

Once Raw Nodes are in common usage this can likely make a big difference
in the GC and other places that just care about the Links.

License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
  • Loading branch information
kevina committed Nov 4, 2016
1 parent 1ca2d42 commit daacdbc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions merkledag/merkledag.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ func decodeBlock(b blocks.Block) (node.Node, error) {
}

func (n *dagService) GetLinks(ctx context.Context, c *cid.Cid) ([]*node.Link, error) {
if c.Codec() == cid.Raw {
return nil, nil
}
node, err := n.Get(ctx, c)
if err != nil {
return nil, err
Expand Down

0 comments on commit daacdbc

Please sign in to comment.