Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] modifications for expected output #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Expand Up @@ -11,3 +11,5 @@ require (
github.com/ipld/go-ipld-prime v0.16.0
github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd73
)

replace github.com/ipld/go-car/v2 => ../go-car/v2
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can link it against ipld/go-car#305 if you car, but was developing the two together. this code demonstration ended up as a test case in that go-car PR

9 changes: 7 additions & 2 deletions main.go
Expand Up @@ -36,7 +36,7 @@ import (
func main() {
// ---------------- create UnixFS DAG in-memory
ls := cidlink.DefaultLinkSystem()
storage := cidlink.Memory{}
storage := cidlink.Memory{Bag: make(map[string][]byte)}
ls.StorageWriteOpener = storage.OpenWrite
ls.StorageReadOpener = func(c linking.LinkContext, lnk datamodel.Link) (io.Reader, error) {
return storage.OpenRead(c, lnk)
Expand Down Expand Up @@ -99,8 +99,13 @@ func createCarv1(ls *linking.LinkSystem, rootCid cid.Cid) *bytes.Buffer {
sel := sb.ExploreInterpretAs("unixfs", sb.MatcherSubset(0, 256*1000))
unixfsnode.AddUnixFSReificationToLinkSystem(ls)
var carbz bytes.Buffer

chooser := dagpb.AddSupportToChooser(func(l datamodel.Link, lc linking.LinkContext) (datamodel.NodePrototype, error) {
return basicnode.Prototype.Any, nil
})

_, err := car.TraverseV1(context.Background(), ls, rootCid, sel.Node(), &carbz, car.StoreIdentityCIDs(false), car.WithoutIndex(),
carv2bs.AllowDuplicatePuts(false), carv2bs.UseWholeCIDs(false))
carv2bs.AllowDuplicatePuts(false), carv2bs.UseWholeCIDs(false), car.WithTraversalPrototypeChooser(chooser))
if err != nil {
panic(err)
}
Expand Down