Conversation
This has always been a link and not an actual CID. Fixing the naming would mean a whole bunch of test code changes for little value, but we can at least make it return `cidlink.Link` explicitly and not `ipld.Link` generally, which means that test code no longer has to type-assert it to `cidlink.Link` to get the `cid.CID` from inside it.
| } | ||
|
|
||
| func RandomCID(t *testing.T) datamodel.Link { | ||
| func RandomCID(t *testing.T) cidlink.Link { |
There was a problem hiding this comment.
I know this would be breaking, but I really wish the method returned a cid.Cid, instead of whatever a cidlink.Link is..
There was a problem hiding this comment.
I know. cidlink.Link is just a link that's implemented with a CID. It's weird because I don't know of any other kinds of links in IPLD? It seems like they have to be CIDs? But technically ipld.Link is a generic interface, and cidlink.Link implements that interface using CIDs, so you have to know you have one to pull the actual CID out.
Ideally, this would be called RandomLink() and RandomCID() would return a cidCid, but…well, someday, I hope.
There was a problem hiding this comment.
I know this would be breaking, but I really wish the method returned a
cid.Cid, instead of whatever acidlink.Linkis..
I mean, at least you can get the cid.Cid out of this now without type asserting...
I feel like this might be my fault...sorry. I would get behind a RandomCID -> RandomLink rename and a new RandomCID method that actually returns a cid.Cid.
|
Hmm, turns out it's not actually a completely non-breaking change. 😕 Maybe it's worth renaming it after all. I'm going to put this on ice until we're a little less busy. |
This has always been a link and not an actual CID. Fixing the naming would mean a whole bunch of test code changes for little value, but we can at least make it return
cidlink.Linkexplicitly and notipld.Linkgenerally, which means that test code no longer has to type-assert it tocidlink.Linkto get thecid.CIDfrom inside it.