diff --git a/package.json b/package.json index e60241e..ffedcbf 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": "^0.4.0", "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()