Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last block info for selectors #418

Merged
merged 7 commits into from
May 19, 2020
Merged

Last block info for selectors #418

merged 7 commits into from
May 19, 2020

Conversation

austinabell
Copy link
Contributor

Summary of changes
Changes introduced in this pull request:

  • Needed for graphsync (last block info is sent in responses)
    • Moved test vectors into submodule to be more easily shared

Reference issue to close (if applicable)

Closes #414

Other information and links

self.last_block = Some(LastBlockInfo {
path: self.path.clone(),
link: cid.clone(),
});
let mut node = resolver.load_link(cid).await.map_err(Error::Link)?;
while let Some(Ipld::Link(c)) = node {
node = resolver.load_link(&c).await.map_err(Error::Link)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would self.last_block's CID not need to be updated here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, so the intention is that the first link traversed is recorded, if you provide the most recent when there are multiple traversals, you could lose the connection from the initial node. (This way you do have a theoretical way to regenerate the connection by following the last block link)

This case is never really hit in practice, because we never link to an ipld node that is a link, but this just handles that edge case so traversal doesn't stop if this is ever found.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the intention is that the first link traversed is recorded

It seems like it's still possible here to traverse several links with maybe some other layers in between, and it will only save the last one. Or do you in that case actually want to save the last one only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But what I mean, is that if you save the last link traversed instead of the first, you can never know how many links were traversed and the last block would just be an Ipld Link, which isn't useful because you'd have to do some custom logic to check the previously visited block to get the original block, and that may not be available if you are only walking matched nodes.

This is all very in depth unnecessarily because this case is never hit in practice for our uses, it's just a benefit to allow this over the go implementations stopping traversal.

ipld/src/selector/mod.rs Show resolved Hide resolved
@austinabell austinabell merged commit ff39f2a into master May 19, 2020
@austinabell austinabell deleted the austin/ipld/lbinfo branch May 19, 2020 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include LastBlock info for selector traversals
3 participants