libp2p-bootstrap
Advanced tools
Comparing version 0.12.1 to 0.12.2
@@ -0,1 +1,10 @@ | ||
## [0.12.2](https://github.com/libp2p/js-libp2p-bootstrap/compare/v0.12.1...v0.12.2) (2021-02-08) | ||
### Features | ||
* add types and update deps ([#111](https://github.com/libp2p/js-libp2p-bootstrap/issues/111)) ([269b807](https://github.com/libp2p/js-libp2p-bootstrap/commit/269b80782c4640dbbb7d66de0345703086c03f24)) | ||
<a name="0.12.1"></a> | ||
@@ -2,0 +11,0 @@ ## [0.12.1](https://github.com/libp2p/js-libp2p-bootstrap/compare/v0.11.0...v0.12.1) (2020-08-11) |
{ | ||
"name": "libp2p-bootstrap", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"description": "Node.js IPFS Implementation of the railing process of a Node through a bootstrap peer list", | ||
@@ -30,4 +30,6 @@ "leadMaintainer": "Vasco Santos <vasco.santos@moxy.studio>", | ||
}, | ||
"types": "dist/src/index.d.ts", | ||
"devDependencies": { | ||
"aegir": "^25.0.0", | ||
"@types/debug": "^4.1.5", | ||
"aegir": "^30.3.0", | ||
"libp2p-interfaces": "^0.4.0" | ||
@@ -34,0 +36,0 @@ }, |
@@ -23,16 +23,42 @@ js-libp2p-bootstrap | ||
```JavaScript | ||
const bootstrap = require('libp2p-bootstrap') | ||
const Libp2p = require('libp2p') | ||
const Bootstrap = require('libp2p-bootstrap') | ||
const TCP = require('libp2p-tcp') | ||
const { NOISE } = require('libp2p-noise') | ||
const MPLEX = require('libp2p-mplex') | ||
const options = { | ||
list: <List of Multiaddrs> | ||
interval: 5000 // ms, default is 10s | ||
let options = { | ||
modules: { | ||
transport: [ TCP ], | ||
peerDiscovery: [ Bootstrap ], | ||
streamMuxer: [ MPLEX ], | ||
encryption: [ NOISE ] | ||
}, | ||
config: { | ||
peerDiscovery: { | ||
[Bootstrap.tag]: { | ||
list: [ // a list of bootstrap peer multiaddrs to connect to on node startup | ||
"/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", | ||
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN", | ||
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa" | ||
], | ||
interval: 5000 // default is 10 ms, | ||
enabled: true | ||
} | ||
} | ||
} | ||
} | ||
const b = new bootstrap(options) | ||
async function start () { | ||
let libp2p = await Libp2p.create(options) | ||
b.on('peer', function (peerInfo) { | ||
// found a new peer | ||
}) | ||
libp2p.on('peer:discovery', function (peerId) { | ||
console.log('found peer: ', peerId.toB58String()) | ||
}) | ||
b.start() | ||
await libp2p.start() | ||
} | ||
start() | ||
``` |
@@ -9,4 +9,5 @@ 'use strict' | ||
const log = debug('libp2p:bootstrap') | ||
log.error = debug('libp2p:bootstrap:error') | ||
const log = Object.assign(debug('libp2p:bootstrap'), { | ||
error: debug('libp2p:bootstrap:error') | ||
}) | ||
@@ -22,6 +23,6 @@ /** | ||
* @param {Array<string>} options.list - the list of peer addresses in multi-address format | ||
* @param {number} [options.interval] - the interval between emitting addresses in milliseconds (default: 10000) | ||
* @param {number} [options.interval = 10000] - the interval between emitting addresses in milliseconds | ||
* | ||
*/ | ||
constructor (options = {}) { | ||
constructor (options = { list: [] }) { | ||
if (!options.list || !options.list.length) { | ||
@@ -46,3 +47,3 @@ throw new Error('Bootstrap requires a list of peer addresses') | ||
this._timer = setInterval(() => this._discoverBootstrapPeers(), this._interval) | ||
log('Starting bootstrap node discovery') | ||
this._discoverBootstrapPeers() | ||
@@ -83,3 +84,3 @@ } | ||
stop () { | ||
clearInterval(this._timer) | ||
if (this._timer) clearInterval(this._timer) | ||
this._timer = null | ||
@@ -86,0 +87,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
0
100
64
203905
3
22
462
2