Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Mar 7, 2024
1 parent e3d3206 commit 7bb3ea0
Show file tree
Hide file tree
Showing 7 changed files with 1,155 additions and 38 deletions.
2 changes: 1 addition & 1 deletion gateway/backend_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func carToLinearBlockGetter(ctx context.Context, reader io.Reader, metrics *Grap
if blkRead.block != nil {
metrics.carBlocksFetchedMetric.Inc()
if !blkRead.block.Cid().Equals(c) {
return nil, errors.New(fmt.Sprintf("received block with cid %s, expected %s", blkRead.block.Cid(), c))
return nil, fmt.Errorf("received block with cid %s, expected %s", blkRead.block.Cid(), c)
}
return blkRead.block, nil
}
Expand Down
9 changes: 4 additions & 5 deletions gateway/backend_remote_2.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ type GraphGateway struct {
baseBackend

fetcher CarFetcher

pc traversal.LinkTargetNodePrototypeChooser

pc traversal.LinkTargetNodePrototypeChooser
metrics *GraphGatewayMetrics
}

Expand Down Expand Up @@ -295,7 +293,8 @@ func resolvePathToLastWithRoots(ctx context.Context, fpath path.ImmutablePath, u
func contentMetadataFromRootsAndRemainder(p path.Path, pathRoots []cid.Cid, terminalCid cid.Cid, remainder []string) ContentPathMetadata {
var rootCid cid.Cid
if len(pathRoots) > 0 {
rootCid = pathRoots[0]
rootCid = pathRoots[len(pathRoots)-1]
pathRoots = pathRoots[:len(pathRoots)]

Check failure on line 297 in gateway/backend_remote_2.go

View workflow job for this annotation

GitHub Actions / go-check / All

should omit second index in slice, s[a:len(s)] is identical to s[a:] (S1010)
} else {
rootCid = terminalCid
}
Expand Down Expand Up @@ -808,7 +807,7 @@ func fetchWithPartialRetries[T any](ctx context.Context, p path.ImmutablePath, i
p = path.FromCid(req.c)
params = req.params
remainderUrl := contentPathToCarUrl(p, params).String()
return fmt.Errorf("received partial response, still need %s", remainderUrl)
return ErrPartialResponse{StillNeed: []string{remainderUrl}}
case <-cctx.Done():
return cctx.Err()
}
Expand Down
Loading

0 comments on commit 7bb3ea0

Please sign in to comment.