From 10783f6731546acc71bb59599947757e2a3c289c 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tooling/car/unixfs.go b/tooling/car/unixfs.go index 7a3496a4c..79d1e2333 100644 --- a/tooling/car/unixfs.go +++ b/tooling/car/unixfs.go @@ -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 { @@ -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 {