This repository was archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathlibp2p-nodejs.js
75 lines (73 loc) · 1.66 KB
/
libp2p-nodejs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use strict'
const TCP = require('libp2p-tcp')
const MulticastDNS = require('libp2p-mdns')
const WS = require('libp2p-websockets')
const KadDHT = require('libp2p-kad-dht')
const GossipSub = require('libp2p-gossipsub')
const Multiplex = require('libp2p-mplex')
const { NOISE } = require('libp2p-noise')
const ipnsUtils = require('../ipns/routing/utils')
module.exports = () => {
return {
dialer: {
maxParallelDials: 150, // 150 total parallel multiaddr dials
maxDialsPerPeer: 4, // Allow 4 multiaddrs to be dialed per peer in parallel
dialTimeout: 10e3 // 10 second dial timeout per peer dial
},
modules: {
transport: [
TCP,
WS
],
streamMuxer: [
Multiplex
],
connEncryption: [
NOISE
],
peerDiscovery: [
MulticastDNS
],
dht: KadDHT,
pubsub: GossipSub
},
config: {
peerDiscovery: {
autoDial: true,
[MulticastDNS.tag]: {
enabled: true
},
// Optimization
// Requiring bootstrap inline in components/libp2p to reduce the cli execution time
// [Bootstrap.tag] = 'bootstrap'
bootstrap: {
enabled: true
}
},
dht: {
kBucketSize: 20,
enabled: false,
clientMode: true,
randomWalk: {
enabled: false
},
validators: {
ipns: ipnsUtils.validator
},
selectors: {
ipns: ipnsUtils.selector
}
},
pubsub: {
enabled: true,
emitSelf: true
}
},
metrics: {
enabled: true
},
peerStore: {
persistence: true
}
}
}