Last active
October 1, 2019 21:50
-
-
Save vasa-develop/8c7b306bef1fcbb735fa1b4a0767e763 to your computer and use it in GitHub Desktop.
SimpleAsWater: Getting Started with Libp2p - NodeJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Multiplex = require('libp2p-mplex') | |
| const SECIO = require('libp2p-secio') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const DEFAULT_OPTS = { | |
| modules: { | |
| transport: [ | |
| TCP | |
| ], | |
| connEncryption: [ | |
| SECIO | |
| ], | |
| streamMuxer: [ | |
| Multiplex | |
| ] | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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