Skip to content

Commit

Permalink
make empty root a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Aug 3, 2023
1 parent 4209e7e commit 3b83506
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gateway/blocks_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ func (bb *BlocksBackend) Head(ctx context.Context, path ImmutablePath) (ContentP
return ContentPathMetadata{}, nil, fmt.Errorf("unsupported UnixFS file type")

Check warning on line 283 in gateway/blocks_backend.go

View check run for this annotation

Codecov / codecov/patch

gateway/blocks_backend.go#L283

Added line #L283 was not covered by tests
}

// emptyRoot is a CAR root with the empty identity CID. CAR files are recommended
// to always include a CID in their root, even if it's just the empty CID.
// https://ipld.io/specs/transport/car/carv1/#number-of-roots
var emptyRoot = []cid.Cid{cid.MustParse("bafkqaaa")}

func (bb *BlocksBackend) GetCAR(ctx context.Context, p ImmutablePath, params CarParams) (ContentPathMetadata, io.ReadCloser, error) {
pathMetadata, err := bb.ResolvePath(ctx, p)
if err != nil {
Expand All @@ -292,7 +297,7 @@ func (bb *BlocksBackend) GetCAR(ctx context.Context, p ImmutablePath, params Car
}

Check warning on line 297 in gateway/blocks_backend.go

View check run for this annotation

Codecov / codecov/patch

gateway/blocks_backend.go#L294-L297

Added lines #L294 - L297 were not covered by tests

var buf bytes.Buffer
cw, err := storage.NewWritable(&buf, []cid.Cid{cid.MustParse("bafkqaaa")}, car.WriteAsCarV1(true))
cw, err := storage.NewWritable(&buf, emptyRoot, car.WriteAsCarV1(true))
if err != nil {
return ContentPathMetadata{}, nil, err
}

Check warning on line 303 in gateway/blocks_backend.go

View check run for this annotation

Codecov / codecov/patch

gateway/blocks_backend.go#L299-L303

Added lines #L299 - L303 were not covered by tests
Expand Down

0 comments on commit 3b83506

Please sign in to comment.