Skip to content

Commit

Permalink
Merge pull request #7467 from filecoin-project/chore/normalize-recurs…
Browse files Browse the repository at this point in the history
…ive-sel-references

Normlize selector use within lotus
  • Loading branch information
magik6k authored Oct 7, 2021
2 parents aed6e8d + a40aa9f commit 734a03c
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions node/impl/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/ipld/go-ipld-prime/traversal"
"github.com/ipld/go-ipld-prime/traversal/selector"
"github.com/ipld/go-ipld-prime/traversal/selector/builder"
selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse"
textselector "github.com/ipld/go-ipld-selector-text-lite"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
Expand All @@ -47,7 +48,6 @@ import (

"github.com/filecoin-project/go-fil-markets/discovery"
rm "github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/go-fil-markets/shared"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/go-fil-markets/storagemarket/network"
"github.com/filecoin-project/go-fil-markets/stores"
Expand Down Expand Up @@ -842,7 +842,7 @@ func (a *API) clientRetrieve(ctx context.Context, order api.RetrievalOrder, ref
}
}

sel := shared.AllSelector()
sel := selectorparse.CommonSelector_ExploreAllRecursively
if order.DatamodelPathSelector != nil {

ssb := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any)
Expand Down Expand Up @@ -1299,21 +1299,23 @@ func (a *API) ClientGenCar(ctx context.Context, ref api.FileRef, outputPath stri
}
defer fs.Close() //nolint:errcheck

// build a dense deterministic CAR (dense = containing filled leaves)
ssb := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any)
allSelector := ssb.ExploreRecursive(
selector.RecursionLimitNone(),
ssb.ExploreAll(ssb.ExploreRecursiveEdge())).Node()
sc := car.NewSelectiveCar(ctx,
fs,
[]car.Dag{{Root: root, Selector: allSelector}},
car.MaxTraversalLinks(config.MaxTraversalLinks),
)
f, err := os.Create(outputPath)
if err != nil {
return err
}
if err = sc.Write(f); err != nil {

// build a dense deterministic CAR (dense = containing filled leaves)
if err := car.NewSelectiveCar(
ctx,
fs,
[]car.Dag{{
Root: root,
Selector: selectorparse.CommonSelector_ExploreAllRecursively,
}},
car.MaxTraversalLinks(config.MaxTraversalLinks),
).Write(
f,
); err != nil {
return xerrors.Errorf("failed to write CAR to output file: %w", err)
}

Expand Down

0 comments on commit 734a03c

Please sign in to comment.