-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implement ipfs refs #2004
Implement ipfs refs #2004
Conversation
24ccb51
to
aaf2d3b
Compare
After talking to @achingbrain I will take a look at making a change to js-ipfs-unixfs-exporter to include the parent CID so that a call to refs can be streamed (instead of collecting all the results, working out each link's parents and only then outputting a result) |
Is refs only for unixfs nodes or should it work with all IPLD nodes? I was originally thinking you’d be talking directly to IPLD for this... |
hmm that's a good question. I'll take a look at exactly what refs does and whether it makes sense to use unixfs exporter |
Looking at the code it seems like js-ipfs-unixfs-exporter does traverse any kind of IPLD object, but only in order to find unix format ipld objects. I will want to do something very similar, but more generic, ie not just for unix format objects. |
It turns out it's actually simple to traverse the refs DAG in js-ipfs with pull-traverse instead of relying on js-ipfs-unix-exporter, which is specifically aimed at unix format files |
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.
🚀
const { print } = require('../utils') | ||
|
||
module.exports = { | ||
command: 'refs-local', |
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.
We should be able to use this as ipfs refs local
i.e. without the hyphen
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.
@alanshaw it seems like it will be tricky to make the parser work with both
ipfs refs <path>
ipfs refs local
I can probably hack it to make it work, but before I do that do you think it would make more sense to the user to give the commands different names instead?
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.
Lets keep compat with go-ipfs - it's not too hacky to detect when path === 'local'
and do the right thing in the refs
handler.
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.
That part is easy, it's making the command line parser / help text auto-formatter understand it that will be a little trickier, I'll see if I can make it work
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.
Good point, please take a look but if it's going to be a big time sink or over complicated then lets forget it.
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 added a command aliaser at the beginning of parsing (unfortunately it's not possible to do with yargs middleware): https://github.com/ipfs/js-ipfs/pull/2004/files#diff-71bd1bde77e38a68f76195b8f85ce19c
@dirkmc I've released |
@alanshaw I think it's good to go 🚀 |
Oh hmm let me fix that commit message... it's failing commitlint |
Can we get some 💚 CI please @dirkmc? |
…s-ipfs into feat/support-file-dom-api * 'feat/support-file-dom-api' of github.com:ipfs/js-ipfs: feat: implement ipfs refs and refs local (#2004)
* 'feat/support-file-dom-api' of github.com:ipfs/js-ipfs: feat: implement ipfs refs and refs local (#2004)
resolves #2012 Depends on - [x] #2004 - [x] ipfs-inactive/js-ipfs-http-client#992 - [x] ipfs-inactive/interface-js-ipfs-core#462 - [x] achingbrain/mortice#1 TODO: - [x] Core (mark and sweep) - [x] CLI - [x] http interface - [x] interface-js-ipfs-core tests ipfs-inactive/interface-js-ipfs-core#462 - [x] nodejs-specific tests - [x] Locking - [x] Tests for locking
* feat: implement ipfs refs * feat: refs support in http api * feat: use ipld instead of unix-fs-exporter for refs * test: add basic refs test * feat: refs local * feat: add refs.localPullStream && refs.localReadableStream * chore: change Ref -> ref * feat: make object.links work with CBOR * feat: handle multiple refs. Better param handling * fix: print refs errors to stderr * chore: add comment to explain cli param parsing * refactor: use streaming for refs local * chore: update interface-ipfs-core package * refactor: cleaner refs param handling * fix: alias 'refs local' to 'refs-local' * refactor: move links retrieval from object to refs * chore: add missing packages * refactor: use streaming for cli refs and refs local * fix: add refs and refs local to command count * fix: refs in browser * fix: restore param parsing behaviour * chore: update interface-ipfs-core * chore: update http-client * chore: update interface-ipfs-core * fix: skip failing config.set test for now * fix: skip failing config.set test in http-api * chore: update interface-ipfs-core and ipfs-http-client * chore: fix ipfs-http-client version
Implement the ipfs refs command:
Depends on ipfs-inactive/js-ipfs-http-client#978