Skip to content

Commit

Permalink
Merge pull request ipld/go-car#357 from leszko/allow-using-walk-func
Browse files Browse the repository at this point in the history
Allow using WalkOption in WriteCar function

This commit was moved from ipld/go-car@bfc8d73
  • Loading branch information
willscott authored Jan 28, 2023
2 parents b4cd7d4 + 8016547 commit b9894f3
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 b9894f3

Please sign in to comment.