This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement bitswap wantlist peer ID param and bitswap unwant (#761)
* fix(bitswap.unwant) Parse CID from arg * feat(bitswap.wantlist) add peer parameter * chore: simplify CID parsing for wantlist and unwant * chore: update interface-ipfs-core dependency * chore: upgrades interface-ipfs-core dependency License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
- Loading branch information
Showing
5 changed files
with
64 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,30 @@ | ||
'use strict' | ||
|
||
const promisify = require('promisify-es6') | ||
const CID = require('cids') | ||
|
||
module.exports = (send) => { | ||
return promisify((callback) => { | ||
return promisify((peerId, opts, callback) => { | ||
if (typeof (peerId) === 'function') { | ||
callback = peerId | ||
opts = {} | ||
peerId = null | ||
} else if (typeof (opts) === 'function') { | ||
callback = opts | ||
opts = {} | ||
} | ||
|
||
if (peerId) { | ||
try { | ||
opts.peer = new CID(peerId).toBaseEncodedString() | ||
} catch (err) { | ||
return callback(err) | ||
} | ||
} | ||
|
||
send({ | ||
path: 'bitswap/wantlist' | ||
path: 'bitswap/wantlist', | ||
qs: opts | ||
}, callback) | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* eslint-env mocha */ | ||
|
||
'use strict' | ||
|
||
const test = require('interface-ipfs-core') | ||
const parallel = require('async/parallel') | ||
|
||
const IPFSApi = require('../../src') | ||
const f = require('../utils/factory') | ||
|
||
const nodes = [] | ||
const common = { | ||
setup: function (callback) { | ||
callback(null, { | ||
spawnNode: (cb) => { | ||
f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { | ||
if (err) { | ||
return cb(err) | ||
} | ||
|
||
nodes.push(_ipfsd) | ||
cb(null, IPFSApi(_ipfsd.apiAddr)) | ||
}) | ||
} | ||
}) | ||
}, | ||
teardown: function (callback) { | ||
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) | ||
} | ||
} | ||
|
||
test.bitswap(common) |