forked from libp2p/js-libp2p
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.js
34 lines (29 loc) · 781 Bytes
/
1.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
/* eslint-disable no-console */
import { createLibp2p } from 'libp2p'
import { TCP } from '@libp2p/tcp'
import { Noise } from '@chainsafe/libp2p-noise'
const createNode = async () => {
const node = await createLibp2p({
addresses: {
// To signal the addresses we want to be available, we use
// the multiaddr format, a self describable address
listen: [
'/ip4/0.0.0.0/tcp/0'
]
},
transports: [
new TCP()
],
connectionEncryption: [
new Noise()
]
})
await node.start()
return node
}
;(async () => {
const node = await createNode()
console.log('node has started (true/false):', node.isStarted())
console.log('listening on:')
node.getMultiaddrs().forEach((ma) => console.log(ma.toString()))
})();