@@ -116,9 +116,12 @@ const MulticastDNS = require('libp2p-mdns')
116
116
const DHT = require (' libp2p-kad-dht' )
117
117
const defaultsDeep = require (' @nodeutils/defaults-deep' )
118
118
const Protector = require (' libp2p-pnet' )
119
+ const DelegatedPeerRouter = require (' libp2p-delegated-peer-routing' )
120
+ const DelegatedContentRouter = require (' libp2p-delegated-content-routing' )
119
121
120
122
class Node extends libp2p {
121
123
constructor (_options ) {
124
+ const peerInfo = _options .peerInfo
122
125
const defaults = {
123
126
// The libp2p modules for this libp2p bundle
124
127
modules: {
@@ -133,8 +136,16 @@ class Node extends libp2p {
133
136
connEncryption: [
134
137
SECIO
135
138
],
136
- // Encryption for private networks. Needs additional private key to work
139
+ /** Encryption for private networks. Needs additional private key to work * */
137
140
// connProtector: new Protector(/*protector specific opts*/),
141
+ /** Enable custom content routers, such as delegated routing **/
142
+ // contentRouting: [
143
+ // new DelegatedContentRouter(peerInfo.id)
144
+ // ],
145
+ /** Enable custom peer routers, such as delegated routing **/
146
+ // peerRouting: [
147
+ // new DelegatedPeerRouter()
148
+ // ],
138
149
peerDiscovery: [
139
150
MulticastDNS
140
151
],
@@ -229,16 +240,17 @@ Required keys in the `options` object:
229
240
230
241
` callback ` is a function with the following ` function (err) {} ` signature, where ` err ` is an Error in case stopping the node fails.
231
242
232
- #### ` libp2p.peerRouting.findPeer(id, callback) `
243
+ #### ` libp2p.peerRouting.findPeer(id, timeout, callback) `
233
244
234
245
> Looks up for multiaddrs of a peer in the DHT
235
246
236
247
- ` id ` : instance of [ PeerId] [ ]
248
+ - ` timeout ` : Number milliseconds
237
249
238
250
#### ` libp2p.contentRouting.findProviders(key, timeout, callback) `
239
251
240
252
- ` key ` : Buffer
241
- - ` timeout ` : Number miliseconds
253
+ - ` timeout ` : Number milliseconds
242
254
243
255
#### ` libp2p.contentRouting.provide(key, callback) `
244
256
@@ -306,14 +318,16 @@ Required keys in the `options` object:
306
318
- ` key ` : Buffer
307
319
- ` value ` : Buffer
308
320
309
- #### ` libp2p.dht.get(key, callback) `
321
+ #### ` libp2p.dht.get(key, maxTimeout, callback) `
310
322
311
323
- ` key ` : Buffer
324
+ - ` maxTimeout ` : Number milliseconds
312
325
313
- #### ` libp2p.dht.getMany(key, nVals, callback) `
326
+ #### ` libp2p.dht.getMany(key, nVals, maxTimeout, callback) `
314
327
315
328
- ` key ` : Buffer
316
329
- ` nVals ` : Number
330
+ - ` maxTimeout ` : Number milliseconds
317
331
318
332
[ PeerInfo ] : https://github.com/libp2p/js-peer-info
319
333
[ PeerId ] : https://github.com/libp2p/js-peer-id
0 commit comments