-
Notifications
You must be signed in to change notification settings - Fork 293
feat: update go-ipld-format and boxo to remove globals #1936
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
feat: update go-ipld-format and boxo to remove globals #1936
Conversation
go.mod
Outdated
github.com/ipfs/boxo v0.8.2-0.20230602131956-922a186d9cef | ||
github.com/ipfs/go-block-format v0.1.2 | ||
github.com/ipfs/go-cid v0.4.0 | ||
github.com/ipfs/go-datastore v0.6.0 | ||
github.com/ipfs/go-ds-badger v0.3.0 | ||
github.com/ipfs/go-ds-badger3 v0.0.2 | ||
github.com/ipfs/go-ds-crdt v0.4.0 | ||
github.com/ipfs/go-ds-crdt v0.4.1-0.20230605203104-b879ef19ed1e | ||
github.com/ipfs/go-ds-leveldb v0.5.0 | ||
github.com/ipfs/go-ds-pebble v0.2.3 | ||
github.com/ipfs/go-fs-lock v0.0.7 | ||
github.com/ipfs/go-ipfs-api v0.6.0 | ||
github.com/ipfs/go-ipfs-cmds v0.9.0 | ||
github.com/ipfs/go-ipld-cbor v0.0.6 | ||
github.com/ipfs/go-ipld-format v0.4.0 | ||
github.com/ipfs/go-ipld-format v0.4.1-0.20230530195241-c3da01c74a06 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: use released of go-ds-crdt and ipfs-lite once those PRs are merged.
f136f3a
to
96df5ae
Compare
var ipldDecoder *ipldlegacy.Decoder | ||
|
||
// create an ipld registry specific to this package | ||
func init() { | ||
ipld.Register(cid.DagProtobuf, merkledag.DecodeProtobufBlock) | ||
ipld.Register(cid.Raw, merkledag.DecodeRawBlock) | ||
ipld.Register(cid.DagCBOR, cbor.DecodeBlock) | ||
mcReg := multicodec.Registry{} | ||
mcReg.RegisterDecoder(cid.DagProtobuf, dagpb.Decode) | ||
mcReg.RegisterDecoder(cid.Raw, raw.Decode) | ||
mcReg.RegisterDecoder(cid.DagCBOR, dagcbor.Decode) | ||
ls := cidlink.LinkSystemUsingMulticodecRegistry(mcReg) | ||
|
||
ipldDecoder = ipldlegacy.NewDecoderWithLS(ls) | ||
ipldDecoder.RegisterCodec(cid.DagProtobuf, dagpb.Type.PBNode, merkledag.ProtoNodeConverter) | ||
ipldDecoder.RegisterCodec(cid.Raw, basicnode.Prototype.Bytes, merkledag.RawNodeConverter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a decision on the type of registry to use here:
- go-ipld-prime codecs with wrappers for dag-pb + raw ( e.g. the initial proposal here )
- go-ipld-prime globals (e.g. including other codecs) with dag-pb + raw wrappers
- go-ipld-format only registry
cc @hsanjuan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you recommend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how the performance of the codecs compares (e.g. the two dag-cbor codecs). I feel like I've heard both are better from different parties.
I'd stay away from global variables though, since less magic makes it more obvious what you do/don't support.
Whether you go with the go-ipld-format codecs and then add go-ipld-legacy wrappers for go-ipld-prime codecs, or use go-ipld-prime codecs with the couple necessary wrappers for dag-pb/raw doesn't make a big difference. I've heard people say the old codecs are faster, and I've heard the inverse too. Haven't had the motivation to benchmark and see though 🤷.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can take what you did here then 🤷
96df5ae
to
4128ab6
Compare
Including this in a separate PR with general dependency upgrades. |
This is related to ipfs/boxo#291 and depends on ipfs/go-ds-crdt#201 and hsanjuan/ipfs-lite#296