diff --git a/src/object/addLink.js b/src/object/addLink.js index 3ed3c7bc5..75087578b 100644 --- a/src/object/addLink.js +++ b/src/object/addLink.js @@ -2,10 +2,9 @@ const promisify = require('promisify-es6') const CID = require('cids') -const cleanMultihash = require('../utils/clean-multihash') module.exports = (send) => { - return promisify((multihash, dLink, opts, callback) => { + return promisify((cid, dLink, opts, callback) => { if (typeof opts === 'function') { callback = opts opts = {} @@ -15,7 +14,7 @@ module.exports = (send) => { } try { - multihash = cleanMultihash(multihash, opts) + cid = new CID(cid) } catch (err) { return callback(err) } @@ -23,9 +22,9 @@ module.exports = (send) => { send({ path: 'object/patch/add-link', args: [ - multihash, + cid.toString(), dLink.name, - cleanMultihash(dLink.cid.buffer) + dLink.cid.toString() ] }, (err, result) => { if (err) { diff --git a/src/object/appendData.js b/src/object/appendData.js index 1fe4ce695..6c6cdb722 100644 --- a/src/object/appendData.js +++ b/src/object/appendData.js @@ -3,13 +3,12 @@ const promisify = require('promisify-es6') const once = require('once') const CID = require('cids') -const cleanMultihash = require('../utils/clean-multihash') const SendOneFile = require('../utils/send-one-file') module.exports = (send) => { const sendOneFile = SendOneFile(send, 'object/patch/append-data') - return promisify((multihash, data, opts, _callback) => { + return promisify((cid, data, opts, _callback) => { if (typeof opts === 'function') { _callback = opts opts = {} @@ -20,12 +19,12 @@ module.exports = (send) => { } try { - multihash = cleanMultihash(multihash, opts) + cid = new CID(cid) } catch (err) { return callback(err) } - sendOneFile(data, { args: [multihash] }, (err, result) => { + sendOneFile(data, { args: [cid.toString()] }, (err, result) => { if (err) { return callback(err) } diff --git a/src/object/get.js b/src/object/get.js index 15228f9b6..a8d44db92 100644 --- a/src/object/get.js +++ b/src/object/get.js @@ -4,7 +4,6 @@ const promisify = require('promisify-es6') const dagPB = require('ipld-dag-pb') const DAGNode = dagPB.DAGNode const DAGLink = dagPB.DAGLink -const bs58 = require('bs58') const CID = require('cids') const LRU = require('lru-cache') const lruOptions = { diff --git a/src/object/links.js b/src/object/links.js index 30196c3ec..41527d998 100644 --- a/src/object/links.js +++ b/src/object/links.js @@ -3,7 +3,7 @@ const promisify = require('promisify-es6') const dagPB = require('ipld-dag-pb') const DAGLink = dagPB.DAGLink -const cleanMultihash = require('../utils/clean-multihash') +const CID = require('cids') const LRU = require('lru-cache') const lruOptions = { max: 128 @@ -12,7 +12,7 @@ const lruOptions = { const cache = new LRU(lruOptions) module.exports = (send) => { - return promisify((multihash, options, callback) => { + return promisify((cid, options, callback) => { if (typeof options === 'function') { callback = options options = {} @@ -22,12 +22,12 @@ module.exports = (send) => { } try { - multihash = cleanMultihash(multihash, options) + cid = new CID(cid) } catch (err) { return callback(err) } - const node = cache.get(multihash) + const node = cache.get(cid.toString()) if (node) { return callback(null, node.links) @@ -35,7 +35,7 @@ module.exports = (send) => { send({ path: 'object/links', - args: multihash + args: cid.toString() }, (err, result) => { if (err) { return callback(err) @@ -44,9 +44,7 @@ module.exports = (send) => { let links = [] if (result.Links) { - links = result.Links.map((l) => { - return new DAGLink(l.Name, l.Size, l.Hash) - }) + links = result.Links.map((l) => new DAGLink(l.Name, l.Size, l.Hash)) } callback(null, links) }) diff --git a/src/object/rmLink.js b/src/object/rmLink.js index 3a45529cf..4726bb216 100644 --- a/src/object/rmLink.js +++ b/src/object/rmLink.js @@ -2,10 +2,9 @@ const promisify = require('promisify-es6') const CID = require('cids') -const cleanMultihash = require('../utils/clean-multihash') module.exports = (send) => { - return promisify((multihash, dLink, opts, callback) => { + return promisify((cid, dLink, opts, callback) => { if (typeof opts === 'function') { callback = opts opts = {} @@ -15,7 +14,7 @@ module.exports = (send) => { } try { - multihash = cleanMultihash(multihash, opts) + cid = new CID(cid) } catch (err) { return callback(err) } @@ -23,7 +22,7 @@ module.exports = (send) => { send({ path: 'object/patch/rm-link', args: [ - multihash, + cid.toString(), dLink.name ] }, (err, result) => { diff --git a/src/object/setData.js b/src/object/setData.js index 7a256ca11..5eb014474 100644 --- a/src/object/setData.js +++ b/src/object/setData.js @@ -3,13 +3,12 @@ const promisify = require('promisify-es6') const once = require('once') const CID = require('cids') -const cleanMultihash = require('../utils/clean-multihash') const SendOneFile = require('../utils/send-one-file') module.exports = (send) => { const sendOneFile = SendOneFile(send, 'object/patch/set-data') - return promisify((multihash, data, opts, _callback) => { + return promisify((cid, data, opts, _callback) => { if (typeof opts === 'function') { _callback = opts opts = {} @@ -20,12 +19,12 @@ module.exports = (send) => { } try { - multihash = cleanMultihash(multihash, opts) + cid = new CID(cid) } catch (err) { return callback(err) } - sendOneFile(data, { args: [multihash] }, (err, result) => { + sendOneFile(data, { args: [cid.toString()] }, (err, result) => { if (err) { return callback(err) } diff --git a/src/object/stat.js b/src/object/stat.js index ba2c2b48c..280e9f8e1 100644 --- a/src/object/stat.js +++ b/src/object/stat.js @@ -1,10 +1,10 @@ 'use strict' const promisify = require('promisify-es6') -const cleanMultihash = require('../utils/clean-multihash') +const CID = require('cids') module.exports = (send) => { - return promisify((multihash, opts, callback) => { + return promisify((cid, opts, callback) => { if (typeof opts === 'function') { callback = opts opts = {} @@ -14,14 +14,14 @@ module.exports = (send) => { } try { - multihash = cleanMultihash(multihash, opts) + cid = new CID(cid) } catch (err) { return callback(err) } send({ path: 'object/stat', - args: multihash + args: cid.toString() }, callback) }) }