-
Notifications
You must be signed in to change notification settings - Fork 54
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
traverse walk function added with tests #127
Conversation
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.
Could you also change it from traverse
to traversal
?
I'm not super jazzed about a new devDependency, sinon is pretty heavy for checking an ordered list of CIDs (and I tend toward minimal dependencies these days, personally!), but that could be refactored out later if need be I suppose.
Looks good otherwise! Though I'm not sure about why check is now complaining about the base exports, I'll have to have a look at that, some new crazy breakage typescript is throwing at us in a non-major release no doubt.
So I tried this out @ ipfs/js-ipfs#3950 and had to make a small modification - the I think I'm OK with this API. @achingbrain what think you? |
Added a thought over @ https://github.com/ipfs/js-ipfs/pull/3950/files#r755899861 that maybe watching for the loader returning Thoughts anyone? |
src/traversal.js
Outdated
* @template T | ||
* @param {Object} options | ||
* @param {CID} options.cid | ||
* @param {(cid: CID) => Promise<Block<T>>} options.load |
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.
@patrickwoodhead let's go with the null
== skip feature for this.
* @param {(cid: CID) => Promise<Block<T>>} options.load | |
* @param {(cid: CID) => Promise<Block<T>|null>} options.load |
Then you can just do a return
if block === null
on the load()
call.
If you could also add some very basic docs onto the README for this that would be helpful too. As you can see the current README is fairly minimal so no need to go overboard unless you're enthusiastic (it's a TODO #47).
Since I've force pushed a rebase and some additional commits to this branch, you'll have to get your local copy updated. git fetch origin
and git rebase origin feat/walk
should do the trick, then you can just push new updates.
When we merge, we'll squash it down to a single commit with a feat:
prefix so this will be a semver-minor release.
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.
I have done the above. Let me know if there is anything still outstanding.
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.
👌 superb! great work @patrickwoodhead
Closes: #118 Basic traversal functionality for deterministic DAG walking with no repeat block visits and support for block skipping. User supplies a block loader, which can be used to watch the block ordering of the walk.
updated ipfs/js-ipfs#3950 to use the newly release 9.5.0, looks good |
Ref: multiformats/js-multiformats#127 Co-authored-by: achingbrain <[email protected]>
Ref: multiformats/js-multiformats#127 Co-authored-by: achingbrain <[email protected]>
This PR aims to fix #118.
Summary of PR
A new file
traverse.js
with a function calledwalk
inside it.walk
is a utility function that allows a use to walk through the links in a block and, for each one, fetch that block using the load function, which is passed in to walk as a parameter.The naming is chosen to align with
go-ipld-prime
.Test cases have been written, which have led to two new dev dependencies being added in this PR:
@ipld/dag-pb
andsinon
.