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 a2a3e3d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tooling/car/unixfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ import (
"github.com/ipfs/go-blockservice"
"github.com/ipfs/go-cid"
format "github.com/ipfs/go-ipld-format"
legacy "github.com/ipfs/go-ipld-legacy"
"github.com/ipfs/go-merkledag"
"github.com/ipfs/go-unixfs/io"
"github.com/ipld/go-car/v2/blockstore"
basicnode "github.com/ipld/go-ipld-prime/node/basic"
"github.com/multiformats/go-multicodec"
)

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

func init() {

format.Register(uint64(multicodec.Json), DecodeProtobufBlock)
format.Register(uint64(multicodec.DagJson), DecodeProtobufBlock)

// 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 a2a3e3d

Please sign in to comment.