Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ipfs-pubsub-peer-monitor

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipfs-pubsub-peer-monitor - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

test/find-peers.test.js

7

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc