feat: remove ipld legacy and format globals in ipld/merkledag#322
feat: remove ipld legacy and format globals in ipld/merkledag#322aschmahmann merged 2 commits intomainfrom
Conversation
| legacy.RegisterCodec(cid.Raw, basicnode.Prototype.Bytes, RawNodeConverter) | ||
| // TODO: Don't require global registries | ||
| func init() { | ||
| d := legacy.NewDecoder() |
There was a problem hiding this comment.
@willscott WDYT about explicitly passing the go-ipld-prime linksystem here instead of requiring the default? This might make it easier for people to get out of the "global defaults" game.
There was a problem hiding this comment.
is there a reason to have this as a global versus the approach i took in ipfs/go-merkledag#104 and making the decoder in the NewDAGService below?
There was a problem hiding this comment.
Initially it was just a stylistic preference that I had since a) it's still a global in 104, it's just a little more subtle b) it's a bit of a DRY thing where I didn't want to accidentally change one instead of the other.
However, I'm now also thinking that given we still have this global we might want to make it settable until we can make relying on a merkledag global registry no longer a thing (especially since it also implicitly hides the go-ipld-prime global registry)
| d.RegisterCodec(cid.DagProtobuf, dagpb.Type.PBNode, ProtoNodeConverter) | ||
| d.RegisterCodec(cid.Raw, basicnode.Prototype.Bytes, RawNodeConverter) | ||
| ipldLegacyDecoder = d |
There was a problem hiding this comment.
@willscott thanks for doing ipfs/go-merkledag#104. I mostly copied it. Although I left the globals up in the global space as a reminder for us to try and exit globals land when it becomes possible 😅
There was a problem hiding this comment.
as a reminder for us to try and exit globals land when it becomes possible
I'm confused by this - in 104 i did exit globals land. - is there a reason not to stay consistent with that in the copy here, since it's the direction we want to go anyway?
There was a problem hiding this comment.
I'm confused by this - in 104 i did exit globals land
We're still stuck with globals:
- The merkledag libraries still have globals. IMO this is bad for the same reasons the other ones were bad, it just turns out the other ones are basically unused independently so for now we can at fairly low cost coalesce here (and solve a problem we currently have)
- There are still go-ipld-prime globals used implicitly in go-ipld-legacy unless we fix that https://github.com/ipfs/go-ipld-legacy/pull/12/files#r1211104340
- Ran out of time to do the kubo PR exercising this (chore: update boxo to version with fewer globals kubo#9907). Maybe it'll be fine to leave this merkledag PR mostly alone (aside from passing in something like a linksystem to go-ipld-legacy). However, to start wrestling control away from the globals we might also want to make the legacy decoder used by merkledag publicly settable (albeit with the various warnings about being careful about using it, and trying to only use it in top-level binaries).
is there a reason not to stay consistent with that in the copy here
If we go with making the go-ipld-legacy decoder publicly settable (and therefore not tied to go-ipld-prime's global registry) then this approach looks much better rather than just being a stylistic difference. If it's just a stylistic difference then 🤷.
f87feff to
9a14e5e
Compare
Codecov Report
@@ Coverage Diff @@
## main #322 +/- ##
==========================================
+ Coverage 49.26% 49.67% +0.41%
==========================================
Files 280 283 +3
Lines 33850 33873 +23
==========================================
+ Hits 16675 16828 +153
+ Misses 15398 15287 -111
+ Partials 1777 1758 -19
|
|
ipfs/kubo#9787 (comment) 🤣 #309 has some merits I see |
9a14e5e to
cca799c
Compare
…gistry instead of a shared global registry
cca799c to
3200229
Compare
|
merging without approval from the other kubo maintainers since I feel like @willscott's review is enough 😄. If someone objects we can fix it up before the boxo release tag. |
Related to #291