generated from orbitdb/repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
56 lines (54 loc) · 1.32 KB
/
index.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
import { identify } from '@libp2p/identify'
import { webSockets } from '@libp2p/websockets'
import { webRTC } from '@libp2p/webrtc'
import { all } from '@libp2p/websockets/filters'
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { gossipsub } from '@chainsafe/libp2p-gossipsub'
import { circuitRelayTransport } from '@libp2p/circuit-relay-v2'
/**
* A basic Libp2p configuration for Node.js nodes.
*/
export const DefaultLibp2pOptions = {
addresses: {
listen: ['/ip4/0.0.0.0/tcp/0/ws']
},
transports: [
webSockets({
filter: all
})
],
connectionEncrypters: [noise()],
streamMuxers: [yamux()],
connectionGater: {
denyDialMultiaddr: () => false
},
services: {
identify: identify(),
pubsub: gossipsub({ allowPublishToZeroTopicPeers: true })
}
}
/**
* A basic Libp2p configuration for browser nodes.
*/
export const DefaultLibp2pBrowserOptions = {
addresses: {
listen: ['/webrtc', '/p2p-circuit']
},
transports: [
webSockets({
filter: all
}),
webRTC(),
circuitRelayTransport()
],
connectionEncrypters: [noise()],
streamMuxers: [yamux()],
connectionGater: {
denyDialMultiaddr: () => false
},
services: {
identify: identify(),
pubsub: gossipsub({ allowPublishToZeroTopicPeers: true })
}
}