You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/peer-and-content-routing/README.md
+33-46
Original file line number
Diff line number
Diff line change
@@ -10,31 +10,27 @@ Content Routing is the category of modules that offer a way to find where conten
10
10
11
11
This example builds on top of the [Protocol and Stream Muxing](../protocol-and-stream-muxing). We need to install `libp2p-kad-dht`, go ahead and `npm install libp2p-kad-dht`. If you want to see the final version, open [1.js](./1.js).
12
12
13
-
First, let's update our bundle to support Peer Routing and Content Routing.
13
+
First, let's update our config to support Peer Routing and Content Routing.
14
14
15
15
```JavaScript
16
-
classMyBundleextendslibp2p {
17
-
constructor (_options) {
18
-
constdefaults= {
19
-
modules: {
20
-
transport: [ TCP ],
21
-
streamMuxer: [ Mplex ],
22
-
connEncryption: [ SECIO ],
23
-
// we add the DHT module that will enable Peer and Content Routing
24
-
dht: KadDHT
25
-
},
26
-
config: {
27
-
dht: {
28
-
// dht must be enabled
29
-
enabled:true,
30
-
kBucketSize:20
31
-
}
32
-
}
16
+
constLibp2p=require('libp2p')
17
+
constKadDHT=require('libp2p-kad-dht')
18
+
19
+
constnode=awaitLibp2p.create({
20
+
modules: {
21
+
transport: [ TCP ],
22
+
streamMuxer: [ Mplex ],
23
+
connEncryption: [ SECIO ],
24
+
// we add the DHT module that will enable Peer and Content Routing
25
+
dht: KadDHT
26
+
},
27
+
config: {
28
+
dht: {
29
+
// dht must be enabled
30
+
enabled:true
33
31
}
34
-
35
-
super(defaultsDeep(_options, defaults))
36
32
}
37
-
}
33
+
})
38
34
```
39
35
40
36
Once that is done, we can use the createNode function we developed in the previous example to create 3 nodes. Connect node 1 to node 2 and node 2 to node 3. We will use node 2 as a way to find the whereabouts of node 3
0 commit comments