ipfs-pubsub-peer-monitor
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "ipfs-pubsub-peer-monitor", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Monitor peers joining and leaving an IPFS PubSub topic", | ||
"main": "src/ipfs-pubsub-peer-monitor.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha --exit" | ||
}, | ||
@@ -13,3 +13,6 @@ "author": "Haad", | ||
"hyperdiff": "^2.0.4" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^5.0.5" | ||
} | ||
} |
@@ -24,3 +24,9 @@ 'use strict' | ||
start () { | ||
this._interval = setInterval(this._pollPeers.bind(this), this._options.pollInterval) | ||
if (this._interval) | ||
this.stop() | ||
this._interval = setInterval( | ||
this._pollPeers.bind(this), | ||
this._options.pollInterval | ||
) | ||
} | ||
@@ -30,5 +36,7 @@ | ||
clearInterval(this._interval) | ||
this._interval = null | ||
} | ||
getPeers () { | ||
async getPeers () { | ||
this._peers = await this._pubsub.peers(this._topic) | ||
return this._peers.slice() | ||
@@ -41,11 +49,10 @@ } | ||
_pollPeers () { | ||
this._pubsub.peers(this._topic, (err, peers) => { | ||
if (err) { | ||
this.emit('error', err) | ||
return // early | ||
} | ||
async _pollPeers () { | ||
try { | ||
const peers = await this._pubsub.peers(this._topic) | ||
this._emitChanges(this._peers, peers) | ||
this._peers = peers | ||
}) | ||
} catch (err) { | ||
this.emit('error', err) | ||
} | ||
} | ||
@@ -52,0 +59,0 @@ |
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
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
7012
6
147
2
1