From b9c9a2d1563c06502135e276b2d8c7c143d94c64 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 23 Aug 2018 10:48:53 -0700 Subject: [PATCH] remove bitswap.unwant fixes #339 --- SPEC/BITSWAP.md | 27 -------------- js/src/bitswap/.tern-port | 1 + js/src/bitswap/index.js | 3 +- js/src/bitswap/unwant.js | 77 --------------------------------------- 4 files changed, 2 insertions(+), 106 deletions(-) create mode 100644 js/src/bitswap/.tern-port delete mode 100644 js/src/bitswap/unwant.js diff --git a/SPEC/BITSWAP.md b/SPEC/BITSWAP.md index 28949c00..d1fb0614 100644 --- a/SPEC/BITSWAP.md +++ b/SPEC/BITSWAP.md @@ -1,35 +1,8 @@ # Bitswap API * [bitswap.wantlist](#bitswapwantlist) -* [bitswap.unwant](#bitswapunwant) * [bitswap.stat](#bitswapstat) -#### `bitswap.unwant` - -> Removes a given block from your wantlist - -##### `Go` **WIP** - -##### `JavaScript` - ipfs.bitswap.unwant(cid, [callback]) - -`cid` is a [cid][cid] which can be passed as: - -- CID, a CID instance -- String, the base58 encoded version of the multihash - -`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful. - - **Example:** - - ```JavaScript - ipfs.bitswap.unwant('QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu', (err) => { - if (err) throw err - console.log('Done') - }) - ``` - -##### `Go` **WIP** - ### `bitswap.wantlist` > Returns the wantlist, optionally filtered by peer ID diff --git a/js/src/bitswap/.tern-port b/js/src/bitswap/.tern-port new file mode 100644 index 00000000..afd86f3d --- /dev/null +++ b/js/src/bitswap/.tern-port @@ -0,0 +1 @@ +36541 \ No newline at end of file diff --git a/js/src/bitswap/index.js b/js/src/bitswap/index.js index 3a5f5f37..34949a7e 100644 --- a/js/src/bitswap/index.js +++ b/js/src/bitswap/index.js @@ -3,8 +3,7 @@ const { createSuite } = require('../utils/suite') const tests = { stat: require('./stat'), - wantlist: require('./wantlist'), - unwant: require('./unwant') + wantlist: require('./wantlist') } module.exports = createSuite(tests) diff --git a/js/src/bitswap/unwant.js b/js/src/bitswap/unwant.js deleted file mode 100644 index ad74e42b..00000000 --- a/js/src/bitswap/unwant.js +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-env mocha */ -/* eslint max-nested-callbacks: ["error", 6] */ -'use strict' - -const waterfall = require('async/waterfall') -const { spawnNodesWithId } = require('../utils/spawn') -const { getDescribe, getIt, expect } = require('../utils/mocha') -const { waitForWantlistKey } = require('./utils') -const { connect } = require('../utils/swarm') - -module.exports = (createCommon, options) => { - const describe = getDescribe(options) - const it = getIt(options) - const common = createCommon() - - describe('.bitswap.unwant', () => { - let ipfsA - let ipfsB - const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR' - - before(function (done) { - // CI takes longer to instantiate the daemon, so we need to increase the - // timeout for the before step - this.timeout(60 * 1000) - - common.setup((err, factory) => { - expect(err).to.not.exist() - - spawnNodesWithId(2, factory, (err, nodes) => { - expect(err).to.not.exist() - - ipfsA = nodes[0] - ipfsB = nodes[1] - - // Add key to the wantlist for ipfsB - ipfsB.block.get(key, () => {}) - - connect(ipfsA, ipfsB.peerId.addresses[0], done) - }) - }) - }) - - after((done) => common.teardown(done)) - - it('should remove a key from the wantlist', (done) => { - waitForWantlistKey(ipfsB, key, (err) => { - expect(err).to.not.exist() - - ipfsB.bitswap.unwant(key, (err) => { - expect(err).to.not.exist() - - ipfsB.bitswap.wantlist((err, list) => { - expect(err).to.not.exist() - expect(list.Keys.every(k => k['/'] !== key)).to.equal(true) - done() - }) - }) - }) - }) - - it('should not remove a key from the wantlist when offline', function (done) { - this.timeout(60 * 1000) - - waterfall([ - (cb) => createCommon().setup(cb), - (factory, cb) => factory.spawnNode(cb), - (node, cb) => node.stop((err) => cb(err, node)) - ], (err, node) => { - expect(err).to.not.exist() - node.bitswap.wantlist((err) => { - expect(err).to.exist() - done() - }) - }) - }) - }) -}