2017-07-05 12:12:51 +01:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const TCP = require('libp2p-tcp')
|
|
|
|
const WS = require('libp2p-websockets')
|
2018-02-19 09:46:11 +00:00
|
|
|
const mplex = require('libp2p-mplex')
|
2020-05-15 15:37:47 +02:00
|
|
|
const { NOISE } = require('libp2p-noise')
|
|
|
|
|
2018-06-28 10:06:25 +02:00
|
|
|
const defaultsDeep = require('@nodeutils/defaults-deep')
|
2017-07-05 12:12:51 +01:00
|
|
|
const libp2p = require('../../..')
|
|
|
|
|
2020-11-30 11:15:09 +01:00
|
|
|
async function createLibp2p(_options) {
|
|
|
|
const defaults = {
|
|
|
|
modules: {
|
|
|
|
transport: [TCP, WS],
|
|
|
|
streamMuxer: [mplex],
|
|
|
|
connEncryption: [NOISE],
|
|
|
|
},
|
2017-07-05 12:12:51 +01:00
|
|
|
}
|
2020-11-30 11:15:09 +01:00
|
|
|
|
|
|
|
return libp2p.create(defaultsDeep(_options, defaults))
|
2017-07-05 12:12:51 +01:00
|
|
|
}
|
|
|
|
|
2020-11-30 11:15:09 +01:00
|
|
|
module.exports = createLibp2p
|