mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-01 15:21:04 +00:00
* chore: examples not using secio * chore(docs): remove unused dep * chore(docs): remove reference of secio in setup * chore(docs): replace circuit secio reference with noise Co-authored-by: Jacob Heun <jacobheun@gmail.com>
32 lines
783 B
JavaScript
32 lines
783 B
JavaScript
/* eslint-disable no-console */
|
|
'use strict'
|
|
|
|
const Libp2p = require('../..')
|
|
const TCP = require('libp2p-tcp')
|
|
const { NOISE } = require('libp2p-noise')
|
|
|
|
const createNode = async () => {
|
|
const node = await Libp2p.create({
|
|
addresses: {
|
|
// To signall 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()}`))
|
|
})();
|