-
Notifications
You must be signed in to change notification settings - Fork 300
Conversation
As far as I can see, I need to upgrade https://github.com/ipfs/interface-ipfs-core too - I see nothing about that in the CONTRIBUTING guide. Could somebody help me with this? I really want this feature in JS client. |
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.
@sweetpalma thanks for the PR 🚀
Yes, we need some tests and docs for this new command in https://github.com/ipfs/interface-ipfs-core would you be willing to send a PR?
This module depends on interface-ipfs-core
. You can use npm link
to try out your new tests locally. See these docs to help you run only your tests while developing. This is where we import the block tests from interface-ipfs-core
.
module.exports = (send) => { | ||
return promisify((args, opts, callback) => { | ||
if (args && CID.isCID(args)) { | ||
args = multihash.toB58String(args.multihash) |
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.
You can just call toString
on the CID instance:
args = multihash.toB58String(args.multihash) | |
args = args.toString() |
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 also need to check if args
is passed as a CID in a buffer. The CID constructor will take a string/buffer/instance so it's usually best to just pass args
to the constructor to nomalise the input to a CID that you can serialize. Something like this:
try {
args = new CID(args).toString()
} catch (err) {
return callback(err)
}
// args is now a valid, serialized (string) CID
if (typeof (opts) === 'function') { | ||
callback = opts | ||
opts = {} | ||
} |
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.
Please also add a opts = opts || {}
after here in case people call ipfs.block.rm(hash, null, (err) => {})
@@ -217,6 +217,7 @@ const ipfs = ipfsClient({ | |||
- [block](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BLOCK.md) | |||
- [`ipfs.block.get(cid, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BLOCK.md#blockget) | |||
- [`ipfs.block.put(block, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BLOCK.md#blockput) | |||
- [`ipfs.block.rm(cid, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BLOCK.md#blockrm) |
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.
This method takes optional options
.
@sweetpalma @alanshaw |
resolved in #1123 |
I've seen a command "ipfs block rm" in a CLI commands lists and HTTP, but seems like it is absent in
js-ipfs-http-client
package. I've opened this basic merge-request that adds it, but I am not sure what else should got here. Tested on my pet project,ipfs.block.rm
worked like a charm.resolves #792