Skip to content

Commit

Permalink
feat: plumb through contexts (#78)
Browse files Browse the repository at this point in the history
This commit was moved from ipfs/go-merkledag@bfaa766
  • Loading branch information
guseggert authored Nov 10, 2021
1 parent f406887 commit 1e8a6de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions ipld/merkledag/merkledag.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ func (n *dagService) Add(ctx context.Context, nd format.Node) error {
return fmt.Errorf("dagService is nil")
}

return n.Blocks.AddBlock(nd)
return n.Blocks.AddBlock(ctx, nd)
}

func (n *dagService) AddMany(ctx context.Context, nds []format.Node) error {
blks := make([]blocks.Block, len(nds))
for i, nd := range nds {
blks[i] = nd
}
return n.Blocks.AddBlocks(blks)
return n.Blocks.AddBlocks(ctx, blks)
}

// Get retrieves a node from the dagService, fetching the block in the BlockService
Expand Down Expand Up @@ -102,7 +102,7 @@ func (n *dagService) GetLinks(ctx context.Context, c cid.Cid) ([]*format.Link, e
}

func (n *dagService) Remove(ctx context.Context, c cid.Cid) error {
return n.Blocks.DeleteBlock(c)
return n.Blocks.DeleteBlock(ctx, c)
}

// RemoveMany removes multiple nodes from the DAG. It will likely be faster than
Expand All @@ -113,7 +113,7 @@ func (n *dagService) Remove(ctx context.Context, c cid.Cid) error {
func (n *dagService) RemoveMany(ctx context.Context, cids []cid.Cid) error {
// TODO(#4608): make this batch all the way down.
for _, c := range cids {
if err := n.Blocks.DeleteBlock(c); err != nil {
if err := n.Blocks.DeleteBlock(ctx, c); err != nil {
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion ipld/merkledag/merkledag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ func TestCidRetention(t *testing.T) {
}

bs := dstest.Bserv()
err = bs.AddBlock(blk)
err = bs.AddBlock(ctx, blk)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 1e8a6de

Please sign in to comment.