Skip to content

chore: update dht #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,25 @@
],
"license": "MIT",
"devDependencies": {
"aegir": "^33.1.0",
"aegir": "^36.0.0",
"delay": "^5.0.0",
"it-pair": "^1.0.0",
"mocha": "^9.0.1",
"p-defer": "^3.0.0",
"sinon": "^9.0.0"
},
"dependencies": {
"cids": "^1.1.5",
"debug": "^4.3.1",
"it-buffer": "^0.1.3",
"it-handshake": "^2.0.0",
"it-length-prefixed": "^5.0.2",
"it-pipe": "^1.1.0",
"it-pushable": "^1.4.0",
"libp2p": "^0.32.0",
"libp2p": "^0.33.0",
"libp2p-bootstrap": "^0.13.0",
"libp2p-floodsub": "^0.27.0",
"libp2p-gossipsub": "^0.11.0",
"libp2p-kad-dht": "^0.23.1",
"libp2p-kad-dht": "^0.26.0",
"libp2p-mplex": "^0.10.0",
"libp2p-noise": "^4.0.0",
"libp2p-tcp": "^0.17.1",
Expand All @@ -69,7 +68,7 @@
"protobufjs": "^6.10.2",
"stream-to-it": "^0.2.0",
"streaming-iterables": "^6.0.0",
"uint8arrays": "^2.1.0",
"uint8arrays": "^3.0.0",
"yargs": "^15.0.2",
"yargs-promise": "^1.1.0"
},
Expand All @@ -79,5 +78,12 @@
"Arve Knudsen <[email protected]>",
"Alex Potsides <[email protected]>",
"Marin Petrunić <[email protected]>"
]
],
"eslintConfig": {
"extends": "ipfs",
"ignorePatterns": [
"*.d.ts",
"src/profocol/index.js"
]
}
}
6 changes: 3 additions & 3 deletions src/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const pipe = require('it-pipe')
const pushable = require('it-pushable')
const StreamHandler = require('./stream-handler')
const { concat } = require('streaming-iterables')
const uint8ArrayFromString = require('uint8arrays/from-string')
const uint8ArrayToString = require('uint8arrays/to-string')
const { fromString: uint8ArrayFromString } = require('uint8arrays/from-string')
const { toString: uint8ArrayToString } = require('uint8arrays/to-string')
const { passThroughUpgrader } = require('./util')
const {
Request,
Expand Down Expand Up @@ -362,7 +362,7 @@ class Daemon {
yield OkResponse({
dht: {
type: DHTResponse.Type.VALUE,
value: value
value: value.val
}
})
} catch (err) {
Expand Down
20 changes: 15 additions & 5 deletions src/libp2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const WS = require('libp2p-websockets')
const Bootstrap = require('libp2p-bootstrap')
const MPLEX = require('libp2p-mplex')
const { NOISE } = require('libp2p-noise')
const KadDHT = require('libp2p-kad-dht')
const KadDHT = require('libp2p-kad-dht/src/kad-dht')
const FloodSub = require('libp2p-floodsub')
const GossipSub = require('libp2p-gossipsub')
const PeerID = require('peer-id')
Expand Down Expand Up @@ -39,7 +39,6 @@ const getPeerId = async (privateKeyPath) => {
* @param {Options} opts
* @param {boolean} opts.quiet
* @param {boolean} opts.bootstrap
* @param {boolean} opts.dht
* @param {boolean} opts.connMgr
* @param {number} opts.connMgrHi
* @param {string} opts.id
Expand All @@ -54,7 +53,6 @@ const createLibp2p = async ({
bootstrapPeers,
hostAddrs,
announceAddrs,
dht,
connMgrLo,
connMgrHi,
id,
Expand Down Expand Up @@ -90,7 +88,19 @@ const createLibp2p = async ({
peerDiscovery: [
Bootstrap
],
dht: KadDHT,
dht: {
// go-libp2p-daemon only has the older single-table DHT instead of the dual lan/wan version
// found in recent go-ipfs versions. unfortunately it's been abandoned so here we simulate
// the older config with the js implementation
create: (opts) => {
return new KadDHT({
...opts,
protocol: '/ipfs/kad/1.0.0',
clientMode: false,
lan: true
})
}
},
pubsub: pubsubRouter === 'floodsub' ? GossipSub : FloodSub
},
config: {
Expand All @@ -109,7 +119,7 @@ const createLibp2p = async ({
}
},
dht: {
enabled: dht,
enabled: true,
kBucketSize: 20
},
pubsub: {
Expand Down