Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
feat: update deps and stop using swarm directly
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Jul 21, 2017
1 parent 0c286db commit a339e06
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -33,7 +33,7 @@ js-libp2p-floodsub
```JavaScript
const FloodSub = require('libp2p-floodsub')

const fsub = new FloodSub(libp2pNodeInstance)
const fsub = new FloodSub(node)

fsub.start((err) => {
if (err) {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -44,16 +44,16 @@
"devDependencies": {
"aegir": "^11.0.2",
"benchmark": "^2.1.4",
"chai": "^4.0.2",
"dirty-chai": "^2.0.0",
"libp2p": "^0.10.0",
"chai": "^4.1.0",
"dirty-chai": "^2.0.1",
"libp2p": "^0.10.1",
"libp2p-secio": "^0.6.8",
"libp2p-spdy": "^0.10.6",
"libp2p-tcp": "^0.10.1",
"lodash.times": "^4.3.2",
"multiaddr": "^2.3.0",
"peer-id": "~0.8.7",
"peer-info": "~0.9.2",
"peer-info": "~0.9.3",
"pre-commit": "^1.2.2"
},
"dependencies": {
Expand Down
8 changes: 3 additions & 5 deletions src/index.js
Expand Up @@ -214,14 +214,12 @@ class FloodSub extends EventEmitter {
this.libp2p.handle(multicodec, this._onConnection)

// Speed up any new peer that comes in my way
this.libp2p.swarm.on('peer-mux-established', this._dialPeer)
this.libp2p.on('peer:connect', this._dialPeer)

// Dial already connected peers
const peerInfos = values(this.libp2p.peerBook.getAll())

asyncEach(peerInfos, (peerInfo, cb) => {
this._dialPeer(peerInfo, cb)
}, (err) => {
asyncEach(peerInfos, (peer, cb) => this._dialPeer(peer, cb), (err) => {
setImmediate(() => {
this.started = true
callback(err)
Expand All @@ -242,7 +240,7 @@ class FloodSub extends EventEmitter {
}

this.libp2p.unhandle(multicodec)
this.libp2p.swarm.removeListener('peer-mux-established', this._dialPeer)
this.libp2p.removeListener('peer:connect', this._dialPeer)

asyncEach(this.peers.values(), (peer, cb) => peer.close(cb), (err) => {
if (err) {
Expand Down

0 comments on commit a339e06

Please sign in to comment.