Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add
traversal.Get
(andtraversal.Progress.Get
), two methods which take aNode
and aPath
, do a little walk, and return the reachedNode
.This is a (long-overdue) helper function. It's the same functionality as has already been available through
traversal.Focus
, but returns values rather than taking a callback parameter, which is more convenient in some cases.This new method also doesn't bother to accumulate Path and LastBlock info into an updated Progress object, because it doesn't return one. If the user wants the Progress info, they should continue to use Focus and a callback -- using a callback encourages clear handling of the scope of the Progress object, which should be desirable anyway.
traversal.Get
doesn't quite work for call-chaining on its own, because it potentially needs to return an error, but composes nicely with other error-redirection systems like themust
package:must.Node(traversal.Get(startNode, ipld.ParsePath("foo/bar"))).Kind()
works, for example (substitute any call you wish to chain in place of.Kind()
).