forked from libp2p/js-libp2p
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1.js
31 lines (26 loc) · 793 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
/* eslint-disable no-console */
'use strict'
const Libp2p = require('../..')
const TCP = require('libp2p-tcp')
const { NOISE } = require('@chainsafe/libp2p-noise')
const createNode = async () => {
const node = await Libp2p.create({
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']
},
modules: {
transport: [TCP],
connEncryption: [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.multiaddrs.forEach((ma) => console.log(`${ma.toString()}/p2p/${node.peerId.toB58String()}`))
})();