Skip to content

Instantly share code, notes, and snippets.

@vasa-develop
Last active October 1, 2019 21:50
Show Gist options
  • Select an option

  • Save vasa-develop/8c7b306bef1fcbb735fa1b4a0767e763 to your computer and use it in GitHub Desktop.

Select an option

Save vasa-develop/8c7b306bef1fcbb735fa1b4a0767e763 to your computer and use it in GitHub Desktop.
SimpleAsWater: Getting Started with Libp2p - NodeJS
const Libp2p = require('libp2p')
const TCP = require('libp2p-tcp')
const defaultsDeep = require('@nodeutils/defaults-deep')
const DEFAULT_OPTS = {
modules: {
transport: [
TCP
]
}
}
class P2PNode extends Libp2p {
constructor (opts) {
super(defaultsDeep(opts, DEFAULT_OPTS))
}
}
module.exports = P2PNode
const Multiplex = require('libp2p-mplex')
const SECIO = require('libp2p-secio')
const DEFAULT_OPTS = {
modules: {
transport: [
TCP
],
connEncryption: [
SECIO
],
streamMuxer: [
Multiplex
]
}
}
const Libp2p = require('libp2p')
const TCP = require('libp2p-tcp')
const Multiplex = require('libp2p-mplex')
const SECIO = require('libp2p-secio')
const defaultsDeep = require('@nodeutils/defaults-deep')
const DEFAULT_OPTS = {
modules: {
transport: [
TCP
],
connEncryption: [
SECIO
],
streamMuxer: [
Multiplex
]
}
}
class P2PNode extends Libp2p {
constructor(opts) {
super(defaultsDeep(opts, DEFAULT_OPTS))
}
}
module.exports = P2PNode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment