-
Notifications
You must be signed in to change notification settings - Fork 37
Clarify that ipld.get(cid) returns an object with keys that are resolvable #141
Comments
Thanks @Mr0grog for the detailed analysis. I'd like to add where things come from. The underlying library for So we could add to the IPLD Format spec that passing in an empty path ( |
I guess I might have misunderstood your points from our discussion on Friday. I’m sorry if I wrote things wrong here (it was meant to be a summarization of what we had agreed on).
OK, so from that perspective, a big part of the problem in ipld/js-ipld-ethereum#25 is that it violates this part of the spec, right? (I’m not sure about bitcoin and zcash, but they look like they might fail if the path is I had thought you were talking about the js-ipld interface, not the interface for a resolver when you mentioned the The two concerns I was really trying to get at here are:
I do feel like it would be an improvement in the API if the value of the |
I think we talked about the same thing. I just brought it up as I'd like to have this issue solved properly on all levels, not only on the highest level (js-ipld) API.
That is correct. The implementations currently don't follow the spec. This is tracked under ipld/interface-ipld-format#34. |
Got it 👍 So between this and what you wrote in ipld/js-ipld-zcash#20, I think this also means we have a bug in the code here — if |
@Mr0grog Thanks for looking into the code, I did as well, but somehow misread it. You are right. So yes, please open an issue. To double-check we have the same understanding: The issue is that |
👍 yep, we are thinking the same thing here. I opened an issue for that in #142. |
With version 0.23 |
In ipld/js-ipld-ethereum#25 @olizilla ran into some issues with the node representation that is returned from
ipld.get(cid)
for Ethereum objects. After I looked into it, it turns out the same issue exists for the Bitcoin and Zcash resolvers.Specifically, when calling
ipld.get(cid)
, some resolvers (dag-pb, dag-cbor, git) return an object where the keys represent resolvable paths. Other resolvers (bitcoin, ethereum, zcash) return an object where the keys don’t represent resolvable paths (it’s just the parsed representation from whatever underlying library is being used). For example:After talking with @vmx on Friday, we decided it was important that the object you get back is a reasonably accurate representation of the IPLD conception of the node — that is, the keys in the on the object should also represent paths you can resolve.
We need to make this requirement clear in the README or some other documentation.
Note: this is somewhat related to ipld/ipld#44, but after discussing with @vmx and @mikeal on Friday, I think we can treat it separately.
One other open question is that it might be important to have a way to get the underlying representation (either the raw bytes or the parsed representation from which we created the IPLD-focused representation [like what the Ethereum resolver currently returns]). What would be the best way to do that? We had three ideas:
Create a separate API, like
ipld.getRawNode(cid, callback)
.Return the raw bytes (and maybe the parsed representation) as special symbol keys so they don’t get serialized, but are still available. e.g:
Return the underlying object (like today) if just getting the CID, but return an IPLD-focused representation if getting the path
/
. e.g:This is probably the least desirable because it’s not super clear and very easy to get wrong.
The text was updated successfully, but these errors were encountered: