Skip to content

Commit 73754b5

Browse files
authored
fix: add ping service where dht is used (#213)
The next major release of the `@libp2p/kad-dht` module introduces a dependency on `@libp2p/ping` so make sure it's in the config.
1 parent 20a2e1e commit 73754b5

File tree

9 files changed

+19
-4
lines changed

9 files changed

+19
-4
lines changed

examples/js-libp2p-example-auto-tls/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ routing table and perform queries:
253253
import { identify, identifyPush } from '@libp2p/identify'
254254
+ import { kadDHT, removePrivateAddressesMapper } from '@libp2p/kad-dht'
255255
import { keychain } from '@libp2p/keychain'
256+
+ import { ping } from '@libp2p/ping'
256257
+ import { tcp } from '@libp2p/tcp'
257258
import { uPnPNAT } from '@libp2p/upnp-nat'
258259
```
@@ -282,6 +283,7 @@ routing table and perform queries:
282283
+ }),
283284
upnp: uPnPNAT(),
284285
identify: identify(),
286+
+ ping: ping(),
285287
```
286288

287289
If you are running on your own network which has better support for varied

examples/js-libp2p-example-auto-tls/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@libp2p/identify": "^3.0.13",
2626
"@libp2p/kad-dht": "^14.1.4",
2727
"@libp2p/keychain": "^5.0.11",
28+
"@libp2p/ping": "^2.0.27",
2829
"@libp2p/upnp-nat": "^3.0.1",
2930
"@libp2p/websockets": "^9.1.0",
3031
"@multiformats/multiaddr-matcher": "^1.6.0",

examples/js-libp2p-example-auto-tls/trust-free.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { loadOrCreateSelfKey } from '@libp2p/config'
1111
import { identify, identifyPush } from '@libp2p/identify'
1212
import { kadDHT, removePrivateAddressesMapper } from '@libp2p/kad-dht'
1313
import { keychain } from '@libp2p/keychain'
14+
import { ping } from '@libp2p/ping'
1415
import { tcp } from '@libp2p/tcp'
1516
import { uPnPNAT } from '@libp2p/upnp-nat'
1617
import { webSockets } from '@libp2p/websockets'
@@ -46,6 +47,7 @@ const libp2p = await createLibp2p({
4647
// needed to run KAD-DHT and to be contacted by libp2p.direct
4748
identify: identify(),
4849
identifyPush: identifyPush(),
50+
ping: ping(),
4951

5052
// used to securely store the certificate for use after a restart
5153
keychain: keychain(),

examples/js-libp2p-example-discovery-mechanisms/1-dht.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { yamux } from '@chainsafe/libp2p-yamux'
55
import { bootstrap } from '@libp2p/bootstrap'
66
import { identify } from '@libp2p/identify'
77
import { kadDHT, removePublicAddressesMapper } from '@libp2p/kad-dht'
8+
import { ping } from '@libp2p/ping'
89
import { tcp } from '@libp2p/tcp'
910
import { createLibp2p } from 'libp2p'
1011
import bootstrappers from './bootstrappers.js'
@@ -27,7 +28,8 @@ const node = await createLibp2p({
2728
peerInfoMapper: removePublicAddressesMapper,
2829
clientMode: false
2930
}),
30-
identify: identify()
31+
identify: identify(),
32+
ping: ping()
3133
}
3234
})
3335

examples/js-libp2p-example-discovery-mechanisms/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@libp2p/identify": "^3.0.0",
2525
"@libp2p/kad-dht": "^14.0.0",
2626
"@libp2p/mdns": "^11.0.0",
27+
"@libp2p/ping": "^2.0.27",
2728
"@libp2p/pubsub-peer-discovery": "^11.0.0",
2829
"@libp2p/tcp": "^10.0.0",
2930
"libp2p": "^2.0.0"

examples/js-libp2p-example-peer-and-content-routing/1.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { noise } from '@chainsafe/libp2p-noise'
44
import { yamux } from '@chainsafe/libp2p-yamux'
55
import { identify, identifyPush } from '@libp2p/identify'
66
import { kadDHT, removePublicAddressesMapper } from '@libp2p/kad-dht'
7+
import { ping } from '@libp2p/ping'
78
import { tcp } from '@libp2p/tcp'
89
import { createLibp2p } from 'libp2p'
910

@@ -23,7 +24,8 @@ const createNode = async () => {
2324
clientMode: false
2425
}),
2526
identify: identify(),
26-
identifyPush: identifyPush()
27+
identifyPush: identifyPush(),
28+
ping: ping()
2729
}
2830
})
2931

examples/js-libp2p-example-peer-and-content-routing/2.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { noise } from '@chainsafe/libp2p-noise'
44
import { yamux } from '@chainsafe/libp2p-yamux'
55
import { identify, identifyPush } from '@libp2p/identify'
66
import { kadDHT, removePublicAddressesMapper } from '@libp2p/kad-dht'
7+
import { ping } from '@libp2p/ping'
78
import { tcp } from '@libp2p/tcp'
89
import all from 'it-all'
910
import { createLibp2p } from 'libp2p'
@@ -24,7 +25,8 @@ const createNode = async () => {
2425
clientMode: false
2526
}),
2627
identify: identify(),
27-
identifyPush: identifyPush()
28+
identifyPush: identifyPush(),
29+
ping: ping()
2830
}
2931
})
3032

examples/js-libp2p-example-peer-and-content-routing/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { noise } from '@chainsafe/libp2p-noise'
2222
import { yamux } from '@chainsafe/libp2p-yamux'
2323
import { identify, identifyPush } from '@libp2p/identify'
2424
import { kadDHT, removePublicAddressesMapper } from '@libp2p/kad-dht'
25+
import { ping } from '@libp2p/ping'
2526
import { tcp } from '@libp2p/tcp'
2627
import { createLibp2p } from 'libp2p'
2728

@@ -41,7 +42,8 @@ const createNode = async () => {
4142
clientMode: false
4243
}),
4344
identify: identify(),
44-
identifyPush: identifyPush()
45+
identifyPush: identifyPush(),
46+
ping: ping()
4547
}
4648
})
4749

examples/js-libp2p-example-peer-and-content-routing/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@chainsafe/libp2p-yamux": "^7.0.0",
2222
"@libp2p/identify": "^3.0.1",
2323
"@libp2p/kad-dht": "^14.0.0",
24+
"@libp2p/ping": "^2.0.27",
2425
"@libp2p/tcp": "^10.0.0",
2526
"it-all": "^3.0.2",
2627
"libp2p": "^2.0.0",

0 commit comments

Comments
 (0)