Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Mar 25, 2024
1 parent a38728d commit 2d272da
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions gateway/backend_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (bb *BlocksBackend) GetCAR(ctx context.Context, p path.ImmutablePath, param

// TODO: support selectors passed as request param: https://github.com/ipfs/kubo/issues/8769
// TODO: this is very slow if blocks are remote due to linear traversal. Do we need deterministic traversals here?
carWriteErr := walkGatewaySimpleSelectorGraph(ctx, p, params, &lsys, pathResolver)
carWriteErr := walkGatewaySimpleSelector(ctx, p, params, &lsys, pathResolver)

// io.PipeWriter.CloseWithError always returns nil.
_ = w.CloseWithError(carWriteErr)
Expand All @@ -362,9 +362,8 @@ func (bb *BlocksBackend) GetCAR(ctx context.Context, p path.ImmutablePath, param
return pathMetadata, r, nil
}

// FIXME(hacdias) fix this and reuse walkGatewaySimpleSelector
// walkGatewaySimpleSelectorGraph walks the subgraph described by the path and terminal element parameters
func walkGatewaySimpleSelectorGraph(ctx context.Context, p path.ImmutablePath, params CarParams, lsys *ipld.LinkSystem, pathResolver resolver.Resolver) error {
// walkGatewaySimpleSelector walks the subgraph described by the path and terminal element parameters
func walkGatewaySimpleSelector(ctx context.Context, p path.ImmutablePath, params CarParams, lsys *ipld.LinkSystem, pathResolver resolver.Resolver) error {
// First resolve the path since we always need to.
lastCid, remainder, err := pathResolver.ResolveToLastNode(ctx, p)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion gateway/backend_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ func (api *GraphGateway) GetCAR(ctx context.Context, path path.ImmutablePath, pa
blockBuffer = nil
}

err = walkGatewaySimpleSelector(ctx, terminalBlk, params.Scope, params.Range, l)
err = walkGatewaySimpleSelector2(ctx, terminalBlk, params.Scope, params.Range, l)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions gateway/backend_graph_traversal.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func getLinksystem(fn getBlock) *ipld.LinkSystem {
return &lsys
}

// walkGatewaySimpleSelector walks the subgraph described by the path and terminal element parameters
func walkGatewaySimpleSelector(ctx context.Context, terminalBlk blocks.Block, dagScope DagScope, entityRange *DagByteRange, lsys *ipld.LinkSystem) error {
// walkGatewaySimpleSelector2 walks the subgraph described by the path and terminal element parameters
func walkGatewaySimpleSelector2(ctx context.Context, terminalBlk blocks.Block, dagScope DagScope, entityRange *DagByteRange, lsys *ipld.LinkSystem) error {
lctx := ipld.LinkContext{Ctx: ctx}
var err error

Expand Down

0 comments on commit 2d272da

Please sign in to comment.