Skip to content

Commit bfc8d73

Browse files
authored
Merge pull request #357 from leszko/allow-using-walk-func
Allow using WalkOption in WriteCar function
2 parents 020b14c + 620c294 commit bfc8d73

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

car.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ type carWriter struct {
4040

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

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

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

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

0 commit comments

Comments
 (0)