-
Notifications
You must be signed in to change notification settings - Fork 37
feat: return cid of last node traversed from ipld.get and friends #181
Conversation
4427d7e
to
61a4440
Compare
We can pass a path to `ipld.get` that makes the resolver attempt to do a graph traversal until it runs out of path segments to resolve. At that point we don't know the `cid` of the node that will be returned, which things like the `unixfs-exporter` need to know.
61a4440
to
4953ea6
Compare
Codecov Report
@@ Coverage Diff @@
## master #181 +/- ##
==========================================
+ Coverage 93.4% 93.43% +0.03%
==========================================
Files 1 1
Lines 197 198 +1
==========================================
+ Hits 184 185 +1
Misses 13 13
Continue to review full report at Codecov.
|
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.
Can you please update the README and add another test for the case when there is a remainderPath
?
Adding a check for the |
@vmx Done. I *think* I'm returning the right CID. That is, if my nodes are: // node1, cid1
{
links: [
cid2
]
}
// node2, cid2
{
links: [
]
} Then this sort of thing happens: ipld.get(cid1, 'Links/0/Hash/Links/1/Data', (err, res) => {
// res.remainderPath === 'Links/1/Data'
// res.cid === cid2 <- because I could not resolve 'Links/1/Data' inside node2
}) Does that look right? |
@achingbrain It looks right. Perhaps we can make it clearer in the README. It is the CID where the remainderPath has its root, right? |
That's a good way of putting it, have updated the README again. |
We can pass a path to
ipld.get
that makes the resolver attempt to do a graph traversal until it runs out of path segments to resolve.At that point we don't know the
cid
of the node that will be returned, which things like theunixfs-exporter
need to know.