From c4cf441dbe5afa7688a5bb47528961dec363d742 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 24 Jan 2020 12:54:34 +0000 Subject: [PATCH 1/8] refactor: return peer ids as strings Depends on: - [ ] https://github.com/ipfs/interface-js-ipfs-core/pull/581 --- package.json | 2 +- src/swarm/peers.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5fe20ecc4..d8f656ee8 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "async": "^3.1.0", "browser-process-platform": "~0.1.1", "go-ipfs-dep": "^0.4.22", - "interface-ipfs-core": "^0.129.0", + "interface-ipfs-core": "ipfs/interface-js-ipfs-core#return-peer-ids-as-strings", "ipfsd-ctl": "^1.0.2", "it-all": "^1.0.1", "it-concat": "^1.0.0", diff --git a/src/swarm/peers.js b/src/swarm/peers.js index f10035e06..8388af49f 100644 --- a/src/swarm/peers.js +++ b/src/swarm/peers.js @@ -1,7 +1,6 @@ 'use strict' const multiaddr = require('multiaddr') -const CID = require('cids') const configure = require('../lib/configure') module.exports = configure(({ ky }) => { @@ -25,7 +24,7 @@ module.exports = configure(({ ky }) => { const info = {} try { info.addr = multiaddr(peer.Addr) - info.peer = new CID(peer.Peer) + info.peer = peer.Peer } catch (error) { info.error = error info.rawPeerInfo = peer From 7779a5a707315bb08d5b6f4f4991d23a93ba56ec Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 27 Jan 2020 14:45:13 +0000 Subject: [PATCH 2/8] fix: returns string peer ids from all api methods --- src/bitswap/stat.js | 2 +- src/dht/find-peer.js | 2 +- src/dht/find-provs.js | 2 +- src/dht/provide.js | 2 +- src/dht/put.js | 2 +- src/dht/query.js | 2 +- src/id.js | 9 ++++++++- src/swarm/addrs.js | 2 +- 8 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/bitswap/stat.js b/src/bitswap/stat.js index e041f5d9d..36101a1f4 100644 --- a/src/bitswap/stat.js +++ b/src/bitswap/stat.js @@ -23,7 +23,7 @@ function toCoreInterface (res) { return { provideBufLen: res.ProvideBufLen, wantlist: (res.Wantlist || []).map(k => new CID(k['/'])), - peers: (res.Peers || []).map(p => new CID(p)), + peers: (res.Peers || []), blocksReceived: new Big(res.BlocksReceived), dataReceived: new Big(res.DataReceived), blocksSent: new Big(res.BlocksSent), diff --git a/src/dht/find-peer.js b/src/dht/find-peer.js index 9d8f517e5..ef5c6c92a 100644 --- a/src/dht/find-peer.js +++ b/src/dht/find-peer.js @@ -37,7 +37,7 @@ module.exports = configure(({ ky }) => { // https://github.com/ipfs/go-ipfs/blob/eb11f569b064b960d1aba4b5b8ca155a3bd2cb21/core/commands/dht.go#L395-L396 for (const { ID, Addrs } of message.Responses) { return { - id: new CID(ID), + id: ID, addrs: (Addrs || []).map(a => multiaddr(a)) } } diff --git a/src/dht/find-provs.js b/src/dht/find-provs.js index 7adbaf38c..e70935dec 100644 --- a/src/dht/find-provs.js +++ b/src/dht/find-provs.js @@ -35,7 +35,7 @@ module.exports = configure(({ ky }) => { if (message.Type === 4 && message.Responses) { for (const { ID, Addrs } of message.Responses) { yield { - id: new CID(ID), + id: ID, addrs: (Addrs || []).map(a => multiaddr(a)) } } diff --git a/src/dht/provide.js b/src/dht/provide.js index f9013bfed..cdcae2f84 100644 --- a/src/dht/provide.js +++ b/src/dht/provide.js @@ -36,7 +36,7 @@ module.exports = configure(({ ky }) => { message.id = new CID(message.id) if (message.responses) { message.responses = message.responses.map(({ ID, Addrs }) => ({ - id: new CID(ID), + id: ID, addrs: (Addrs || []).map(a => multiaddr(a)) })) } else { diff --git a/src/dht/put.js b/src/dht/put.js index 6d0ecf6fc..8dc924f7a 100644 --- a/src/dht/put.js +++ b/src/dht/put.js @@ -38,7 +38,7 @@ module.exports = configure(({ ky }) => { message.id = new CID(message.id) if (message.responses) { message.responses = message.responses.map(({ ID, Addrs }) => ({ - id: new CID(ID), + id: ID, addrs: (Addrs || []).map(a => multiaddr(a)) })) } diff --git a/src/dht/query.js b/src/dht/query.js index 1628c0cc8..b2b878572 100644 --- a/src/dht/query.js +++ b/src/dht/query.js @@ -26,7 +26,7 @@ module.exports = configure(({ ky }) => { message = toCamel(message) message.id = new CID(message.id) message.responses = (message.responses || []).map(({ ID, Addrs }) => ({ - id: new CID(ID), + id: ID, addrs: (Addrs || []).map(a => multiaddr(a)) })) yield message diff --git a/src/id.js b/src/id.js index d6080ea67..cfec69d3d 100644 --- a/src/id.js +++ b/src/id.js @@ -2,6 +2,7 @@ const configure = require('./lib/configure') const toCamel = require('./lib/object-to-camel') +const multiaddr = require('multiaddr') module.exports = configure(({ ky }) => { return async options => { @@ -14,6 +15,12 @@ module.exports = configure(({ ky }) => { searchParams: options.searchParams }).json() - return toCamel(res) + const output = toCamel(res) + + if (output.addresses) { + output.addresses = output.addresses.map(ma => multiaddr(ma)) + } + + return output } }) diff --git a/src/swarm/addrs.js b/src/swarm/addrs.js index 25bd98d02..79026f0fe 100644 --- a/src/swarm/addrs.js +++ b/src/swarm/addrs.js @@ -16,7 +16,7 @@ module.exports = configure(({ ky }) => { }).json() return Object.keys(res.Addrs).map(id => ({ - id: new CID(id), + id, addrs: (res.Addrs[id] || []).map(a => multiaddr(a)) })) } From 0deb9476cbc870cb9dadd2214fac43d393527832 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 27 Jan 2020 14:59:31 +0000 Subject: [PATCH 3/8] chore: fix linting --- src/swarm/addrs.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/swarm/addrs.js b/src/swarm/addrs.js index 79026f0fe..c4b6576f6 100644 --- a/src/swarm/addrs.js +++ b/src/swarm/addrs.js @@ -1,6 +1,5 @@ 'use strict' -const CID = require('cids') const multiaddr = require('multiaddr') const configure = require('../lib/configure') From 548646db861ac3c9a6e05c98b26e651d401ad4f5 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 29 Jan 2020 14:02:07 +0000 Subject: [PATCH 4/8] chore: remove gh url --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8f656ee8..12485505b 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "async": "^3.1.0", "browser-process-platform": "~0.1.1", "go-ipfs-dep": "^0.4.22", - "interface-ipfs-core": "ipfs/interface-js-ipfs-core#return-peer-ids-as-strings", + "interface-ipfs-core": "^0.130.0", "ipfsd-ctl": "^1.0.2", "it-all": "^1.0.1", "it-concat": "^1.0.0", From 5e059e8e17d4ca2ce6af3198c1d4737f24beb621 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 29 Jan 2020 14:04:11 +0000 Subject: [PATCH 5/8] chore: update ipfsd-ctl --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 12485505b..502ec81ef 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "browser-process-platform": "~0.1.1", "go-ipfs-dep": "^0.4.22", "interface-ipfs-core": "^0.130.0", - "ipfsd-ctl": "^1.0.2", + "ipfsd-ctl": "^2.0.0", "it-all": "^1.0.1", "it-concat": "^1.0.0", "it-pipe": "^1.1.0", From 20257002b8177393ab1c825722252005dba2b86d Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 29 Jan 2020 23:35:24 +0000 Subject: [PATCH 6/8] fix: use gh url for ipfsd-ctl --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 502ec81ef..7702bcc6e 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "browser-process-platform": "~0.1.1", "go-ipfs-dep": "^0.4.22", "interface-ipfs-core": "^0.130.0", - "ipfsd-ctl": "^2.0.0", + "ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#only-require-http-client-if-not-specified", "it-all": "^1.0.1", "it-concat": "^1.0.0", "it-pipe": "^1.1.0", From 0a2c12b0c0d184c0dbd2e32330ae8c97b187d7c7 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 29 Jan 2020 23:48:10 +0000 Subject: [PATCH 7/8] fix: use version of interface tests without js-ipfs --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7702bcc6e..e94c2a9bc 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "async": "^3.1.0", "browser-process-platform": "~0.1.1", "go-ipfs-dep": "^0.4.22", - "interface-ipfs-core": "^0.130.0", + "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#do-not-assume-js-ipfs", "ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#only-require-http-client-if-not-specified", "it-all": "^1.0.1", "it-concat": "^1.0.0", From b58ea81ec5205db2b38ffec0b4b981a0a3c044b4 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 31 Jan 2020 12:21:53 +0000 Subject: [PATCH 8/8] chore: remove gh urls --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e94c2a9bc..844f26807 100644 --- a/package.json +++ b/package.json @@ -68,8 +68,8 @@ "async": "^3.1.0", "browser-process-platform": "~0.1.1", "go-ipfs-dep": "^0.4.22", - "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#do-not-assume-js-ipfs", - "ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#only-require-http-client-if-not-specified", + "interface-ipfs-core": "^0.131.0", + "ipfsd-ctl": "^2.1.0", "it-all": "^1.0.1", "it-concat": "^1.0.0", "it-pipe": "^1.1.0",