Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

feat: return cid of last node traversed from ipld.get and friends #181

Merged
merged 4 commits into from
Nov 19, 2018

Conversation

achingbrain
Copy link
Member

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.

@ghost ghost assigned achingbrain Nov 15, 2018
@ghost ghost added the status/in-progress In progress label Nov 15, 2018
@achingbrain achingbrain requested a review from vmx November 15, 2018 12:18
@achingbrain achingbrain force-pushed the return-cid-after-ipld-get-traversal branch 2 times, most recently from 4427d7e to 61a4440 Compare November 15, 2018 12:19
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.
@achingbrain achingbrain force-pushed the return-cid-after-ipld-get-traversal branch from 61a4440 to 4953ea6 Compare November 15, 2018 12:19
@codecov
Copy link

codecov bot commented Nov 15, 2018

Codecov Report

Merging #181 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/index.js 93.43% <100%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 62b0bf2...b9aabea. Read the comment docs.

Copy link
Member

@vmx vmx left a 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?

@vmx
Copy link
Member

vmx commented Nov 15, 2018

Adding a check for the cid to an existing test is good enough.

@achingbrain
Copy link
Member Author

@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?

@vmx
Copy link
Member

vmx commented Nov 15, 2018

@achingbrain It looks right. Perhaps we can make it clearer in the README. It is the CID where the remainderPath has its root, right?

@achingbrain
Copy link
Member Author

That's a good way of putting it, have updated the README again.

README.md Outdated Show resolved Hide resolved
@vmx vmx merged commit ebcc541 into master Nov 19, 2018
@ghost ghost removed the status/in-progress In progress label Nov 19, 2018
@vmx vmx deleted the return-cid-after-ipld-get-traversal branch November 19, 2018 11:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants