From 3a5948aedc6ee9f6a904b311611a12f99dca70aa Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Fri, 17 Apr 2020 22:42:18 +0200 Subject: [PATCH 1/2] chore: remove peer-info from api --- package.json | 5 ++--- src/dht.js | 31 +++++++++---------------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index e60241e..fe23cbf 100644 --- a/package.json +++ b/package.json @@ -51,11 +51,10 @@ "err-code": "^2.0.0", "it-handshake": "^1.0.1", "it-length-prefixed": "^3.0.0", - "libp2p-daemon": "^0.3.0", + "libp2p-daemon": "libp2p/js-libp2p-daemon#chore/update-peer-store-api", "libp2p-tcp": "^0.14.2", "multiaddr": "^7.2.1", - "peer-id": "~0.13.3", - "peer-info": "~0.17.0" + "peer-id": "~0.13.3" }, "contributors": [ "Arve Knudsen ", diff --git a/src/dht.js b/src/dht.js index 7d10746..5b18721 100644 --- a/src/dht.js +++ b/src/dht.js @@ -2,7 +2,6 @@ const CID = require('cids') const PeerID = require('peer-id') -const PeerInfo = require('peer-info') const multiaddr = require('multiaddr') const errcode = require('err-code') @@ -112,16 +111,10 @@ class DHT { throw errcode(new Error(response.error.msg), 'ERR_DHT_FIND_PEER_FAILED') } - const receivedPeerId = PeerID.createFromBytes(response.dht.peer.id) - const peerInfo = new PeerInfo(receivedPeerId) - - response.dht.peer.addrs.forEach((addr) => { - const ma = multiaddr(addr) - - peerInfo.multiaddrs.add(ma) - }) - - return peerInfo + return { + id: PeerID.createFromBytes(response.dht.peer.id), + addrs: response.dht.peer.addrs.map((a) => multiaddr(a)) + } } /** @@ -193,16 +186,10 @@ class DHT { // Stream values if (response.type === DHTResponse.Type.VALUE) { - const peerId = PeerID.createFromBytes(response.peer.id) - const peerInfo = new PeerInfo(peerId) - - response.peer.addrs.forEach((addr) => { - const ma = multiaddr(addr) - - peerInfo.multiaddrs.add(ma) - }) - - yield peerInfo + yield { + id: PeerID.createFromBytes(response.peer.id), + addrs: response.peer.addrs.map((a) => multiaddr(a)) + } } else { // Unexpected message received await sh.close() @@ -252,7 +239,7 @@ class DHT { if (response.type === DHTResponse.Type.VALUE) { const peerId = PeerID.createFromBytes(response.value) - yield new PeerInfo(peerId) + yield { id: peerId } } else { // Unexpected message received await sh.close() From 06d8ab98f51305be77e84dae959a6e62290b94ab Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Fri, 5 Jun 2020 16:24:22 +0200 Subject: [PATCH 2/2] chore: use new libp2p-daemon --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fe23cbf..ffedcbf 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "err-code": "^2.0.0", "it-handshake": "^1.0.1", "it-length-prefixed": "^3.0.0", - "libp2p-daemon": "libp2p/js-libp2p-daemon#chore/update-peer-store-api", + "libp2p-daemon": "^0.4.0", "libp2p-tcp": "^0.14.2", "multiaddr": "^7.2.1", "peer-id": "~0.13.3"