Skip to content

Commit

Permalink
Allow using WalkOption in WriteCar function
Browse files Browse the repository at this point in the history
This commit was moved from ipld/go-car@620c294
  • Loading branch information
leszko committed Jan 27, 2023
1 parent b4cd7d4 commit 8016547
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ipld/car/car.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ type carWriter struct {

type WalkFunc func(format.Node) ([]*format.Link, error)

func WriteCar(ctx context.Context, ds format.NodeGetter, roots []cid.Cid, w io.Writer) error {
return WriteCarWithWalker(ctx, ds, roots, w, DefaultWalkFunc)
func WriteCar(ctx context.Context, ds format.NodeGetter, roots []cid.Cid, w io.Writer, options ...merkledag.WalkOption) error {
return WriteCarWithWalker(ctx, ds, roots, w, DefaultWalkFunc, options...)
}

func WriteCarWithWalker(ctx context.Context, ds format.NodeGetter, roots []cid.Cid, w io.Writer, walk WalkFunc) error {
func WriteCarWithWalker(ctx context.Context, ds format.NodeGetter, roots []cid.Cid, w io.Writer, walk WalkFunc, options ...merkledag.WalkOption) error {

h := &CarHeader{
Roots: roots,
Expand All @@ -58,7 +58,7 @@ func WriteCarWithWalker(ctx context.Context, ds format.NodeGetter, roots []cid.C
cw := &carWriter{ds: ds, w: w, walk: walk}
seen := cid.NewSet()
for _, r := range roots {
if err := merkledag.Walk(ctx, cw.enumGetLinks, r, seen.Visit); err != nil {
if err := merkledag.Walk(ctx, cw.enumGetLinks, r, seen.Visit, options...); err != nil {
return err
}
}
Expand Down

0 comments on commit 8016547

Please sign in to comment.