Skip to content

Commit f3d0430

Browse files
authored
deps: update to latest circuit relay transport (#183)
Updates examples to use the latest version
1 parent 80bdaa7 commit f3d0430

File tree

10 files changed

+33
-26
lines changed

10 files changed

+33
-26
lines changed

examples/js-libp2p-example-browser-pubsub/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const clean = (line) => line.replaceAll('\n', '')
3838
const libp2p = await createLibp2p({
3939
addresses: {
4040
listen: [
41+
// make a reservation on any discovered relays - this will let other
42+
// peers use the relay to contact us
43+
'/p2p-circuit',
4144
// create listeners for incoming WebRTC connection attempts on on all
4245
// available Circuit Relay connections
4346
'/webrtc'
@@ -52,11 +55,7 @@ const libp2p = await createLibp2p({
5255
// support dialing/listening on WebRTC addresses
5356
webRTC(),
5457
// support dialing/listening on Circuit Relay addresses
55-
circuitRelayTransport({
56-
// make a reservation on any discovered relays - this will let other
57-
// peers use the relay to contact us
58-
discoverRelays: 1
59-
})
58+
circuitRelayTransport()
6059
],
6160
// a connection encrypter is necessary to dial the relay
6261
connectionEncrypters: [noise()],

examples/js-libp2p-example-browser-pubsub/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@chainsafe/libp2p-gossipsub": "^14.0.0",
2525
"@chainsafe/libp2p-noise": "^16.0.0",
2626
"@chainsafe/libp2p-yamux": "^7.0.0",
27-
"@libp2p/circuit-relay-v2": "^2.0.0",
27+
"@libp2p/circuit-relay-v2": "^3.0.0",
2828
"@libp2p/dcutr": "^2.0.0",
2929
"@libp2p/identify": "^3.0.0",
3030
"@libp2p/webrtc": "^5.0.0",

examples/js-libp2p-example-circuit-relay/README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
- [0. Setup the example](#0-setup-the-example)
1313
- [1. Set up a relay node](#1-set-up-a-relay-node)
14-
- [2. Set up a listener node with `discoverRelays` Enabled](#2-set-up-a-listener-node-with-discoverrelays-enabled)
14+
- [2. Set up a listener node with a circuit relay address](#2-set-up-a-listener-node-with-a-circuit-relay-address)
1515
- [3. Set up a dialer node for testing connectivity](#3-set-up-a-dialer-node-for-testing-connectivity)
1616
- [4. What is next?](#4-what-is-next)
1717
- [Need help?](#need-help)
@@ -88,7 +88,7 @@ Listening on:
8888
/ip4/192.168.1.120/tcp/61592/ws/p2p/QmWDn2LY8nannvSWJzruUYoLZ4vV83vfCBwd8DipvdgQc3
8989
```
9090

91-
## 2. Set up a listener node with `discoverRelays` Enabled
91+
## 2. Set up a listener node with a circuit relay address
9292

9393
One of the typical use cases for Circuit Relay is nodes behind a NAT or browser
9494
nodes due to their inability to expose a public address.
@@ -111,11 +111,14 @@ if (!relayAddr) {
111111
}
112112

113113
const node = await createLibp2p({
114+
addresses: {
115+
listen: [
116+
'/p2p-circuit'
117+
]
118+
},
114119
transports: [
115120
webSockets(),
116-
circuitRelayTransport({
117-
discoverRelays: 2
118-
})
121+
circuitRelayTransport()
119122
],
120123
connectionEncrypters: [
121124
noise()

examples/js-libp2p-example-circuit-relay/listener.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ async function main () {
1515
}
1616

1717
const node = await createLibp2p({
18+
addresses: {
19+
listen: [
20+
'/p2p-circuit'
21+
]
22+
},
1823
transports: [
1924
webSockets(),
20-
circuitRelayTransport({
21-
discoverRelays: 2
22-
})
25+
circuitRelayTransport()
2326
],
2427
connectionEncrypters: [
2528
noise()

examples/js-libp2p-example-circuit-relay/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"dependencies": {
1919
"@chainsafe/libp2p-noise": "^16.0.0",
2020
"@chainsafe/libp2p-yamux": "^7.0.0",
21-
"@libp2p/circuit-relay-v2": "^2.0.0",
21+
"@libp2p/circuit-relay-v2": "^3.0.0",
2222
"@libp2p/identify": "^3.0.0",
2323
"@libp2p/websockets": "^9.0.0",
2424
"@multiformats/multiaddr": "^12.3.1",

examples/js-libp2p-example-delegated-routing/src/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ <h1>Delegated Routing</h1>
1616
<form id="findProvidersForm">
1717
<label>
1818
Find providers of CID:
19-
<input type="text" value="" id="find-providers-input" />
19+
<input type="text" value="bafybeiczsscdsbs7ffqz55asqdf3smv6klcw3gofszvwlyarci47bgf354" id="find-providers-input" />
2020
<input type="submit" value="Find Providers" id="find-providers-button" />
2121
</label>
2222
</form>
2323
<form id="findPeerForm">
2424
<label>
2525
Find peer:
26-
<input type="text" value="" id="find-peer-input" />
26+
<input type="text" value="QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN" id="find-peer-input" />
2727
<input type="submit" value="Find PeerInfo" id="find-peer-button" />
2828
</label>
2929
</form>

examples/js-libp2p-example-delegated-routing/test/index.spec.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ async function spawnServer () {
2727
multiaddrs: [],
2828
protocols: []
2929
}
30+
},
31+
findPeer: async function () {
32+
return {
33+
id: peerIdFromString('QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN'),
34+
multiaddrs: []
35+
}
3036
}
3137
}]
3238
})
@@ -69,10 +75,7 @@ test.describe('delegated routing example:', () => {
6975
await page.click(findProvidersBtn)
7076

7177
const outputLocator = page.locator(output)
72-
await expect(outputLocator).toContainText('[', {
73-
// we depend on an external service and it can take a long time to respond
74-
timeout: 5 * 60_000
75-
})
78+
await expect(outputLocator).toContainText('[')
7679
})
7780

7881
test('should find peer using the delegate', async ({ page, context }) => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@chainsafe/libp2p-noise": "^16.0.0",
2121
"@chainsafe/libp2p-yamux": "^7.0.0",
2222
"@libp2p/bootstrap": "^11.0.0",
23-
"@libp2p/circuit-relay-v2": "^2.0.0",
23+
"@libp2p/circuit-relay-v2": "^3.0.0",
2424
"@libp2p/identify": "^3.0.0",
2525
"@libp2p/kad-dht": "^14.0.0",
2626
"@libp2p/mdns": "^11.0.0",

examples/js-libp2p-example-webrtc-private-to-private/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ let chatStream
2727
const node = await createLibp2p({
2828
addresses: {
2929
listen: [
30+
'/p2p-circuit',
3031
'/webrtc'
3132
]
3233
},
@@ -35,9 +36,7 @@ const node = await createLibp2p({
3536
filter: filters.all
3637
}),
3738
webRTC(),
38-
circuitRelayTransport({
39-
discoverRelays: 1
40-
})
39+
circuitRelayTransport()
4140
],
4241
connectionEncrypters: [noise()],
4342
streamMuxers: [yamux()],

examples/js-libp2p-example-webrtc-private-to-private/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"@chainsafe/libp2p-noise": "^16.0.0",
1616
"@chainsafe/libp2p-yamux": "^7.0.0",
17-
"@libp2p/circuit-relay-v2": "^2.0.0",
17+
"@libp2p/circuit-relay-v2": "^3.0.0",
1818
"@libp2p/identify": "^3.0.1",
1919
"@libp2p/ping": "^2.0.1",
2020
"@libp2p/webrtc": "^5.0.0",

0 commit comments

Comments
 (0)