-
Notifications
You must be signed in to change notification settings - Fork 300
fix: added rm method for blocks #910
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,31 @@ | ||||||
'use strict' | ||||||
|
||||||
const promisify = require('promisify-es6') | ||||||
const CID = require('cids') | ||||||
const multihash = require('multihashes') | ||||||
|
||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. You can just call
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also need to check if 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 commentThe reason will be displayed to describe this comment to others. Learn more. Please also add a |
||||||
|
||||||
const request = { | ||||||
path: 'block/rm', | ||||||
args: args, | ||||||
qs: opts | ||||||
} | ||||||
|
||||||
// Transform the response from { Key, Size } objects to { key, size } objects | ||||||
const transform = (stats, callback) => { | ||||||
callback(null) | ||||||
} | ||||||
|
||||||
send.andTransform(request, transform, callback) | ||||||
}) | ||||||
} |
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
.