From a2a3e3da2526e275fb98eabc9d7872a4a008a93f Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 27 Mar 2023 17:55:25 +0200 Subject: [PATCH] wip: load json --- tooling/car/unixfs.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tooling/car/unixfs.go b/tooling/car/unixfs.go index 7a3496a4c..b7aa993aa 100644 --- a/tooling/car/unixfs.go +++ b/tooling/car/unixfs.go @@ -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 { @@ -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 {