Skip to content

Commit

Permalink
wip: load json
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta committed Mar 27, 2023
1 parent 942a53a commit 10783f6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tooling/car/unixfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (
"github.com/ipfs/go-merkledag"
"github.com/ipfs/go-unixfs/io"
"github.com/ipld/go-car/v2/blockstore"
"github.com/ipld/go-ipld-prime/codec/dagjson"
"github.com/ipld/go-ipld-prime/codec/json"
"github.com/multiformats/go-multicodec"
)

type UnixfsDag struct {
Expand All @@ -23,6 +26,16 @@ type UnixfsDag struct {
links map[string]*UnixfsDag
}

func init() {
format.Register(uint64(multicodec.Json), json.Decode)
format.Register(uint64(multicodec.DagJson), dagjson.Decode)

// TODO: register the json codec (0x200) so that merkleDAG nodes can be decoded
// legacy.RegisterCodec(uint64(multicodec.Json), basicnode.Prototype.Any, )
// legacy.RegisterCodec(uint64(multicodec.DagJson), basicnode.Prototype.Any, )
}


func newUnixfsDagFromCar(file string) (*UnixfsDag, error) {
bs, err := blockstore.OpenReadOnly(file)
if err != nil {
Expand Down

0 comments on commit 10783f6

Please sign in to comment.