Skip to content

Commit

Permalink
feat: simplify circuit loading
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov committed Aug 3, 2017
1 parent 12b0dd9 commit 82a86ad
Show file tree
Hide file tree
Showing 6 changed files with 455 additions and 460 deletions.
24 changes: 7 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@
"homepage": "https://github.com/libp2p/js-libp2p",
"dependencies": {
"async": "^2.5.0",
"libp2p-ping": "~0.5.0",
"libp2p-swarm": "~0.31.0",
"libp2p-circuit": "0.0.2",
"libp2p-ping": "~0.4.0",
"libp2p-swarm": "~0.29.1",
"mafmt": "^2.1.8",
"multiaddr": "^2.3.0",
"peer-book": "~0.5.0",
"peer-id": "~0.9.0",
"peer-info": "~0.10.0"
"peer-book": "~0.4.0",
"peer-id": "~0.8.7",
"peer-info": "~0.9.2"
},
"devDependencies": {
"aegir": "^11.0.2",
Expand All @@ -70,17 +71,6 @@
"electron-webrtc": "^0.3.0",
"wrtc": "0.0.62"
},
"dependencies": {
"async": "^2.5.0",
"libp2p-ping": "~0.4.0",
"libp2p-swarm": "~0.29.1",
"libp2p-circuit": "~0.0.1",
"mafmt": "^2.1.8",
"multiaddr": "^2.3.0",
"peer-book": "~0.4.0",
"peer-id": "~0.8.7",
"peer-info": "~0.9.2"
},
"contributors": [
"Chris Bratlien <[email protected]>",
"David Dias <[email protected]>",
Expand All @@ -90,4 +80,4 @@
"greenkeeperio-bot <[email protected]>",
"mayerwin <[email protected]>"
]
}
}
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const PeerInfo = require('peer-info')
const PeerBook = require('peer-book')
const mafmt = require('mafmt')
const multiaddr = require('multiaddr')
const Circuit = require('libp2p-circuit')

exports = module.exports

Expand Down Expand Up @@ -43,9 +44,6 @@ class Node extends EventEmitter {
// If muxer exists, we can use Identify
this.swarm.connection.reuse()

// If muxer exists, we can use Relay for listening/dialing
this.swarm.connection.enableRelayDialing(_options.relay)

// Received incommind dial and muxer upgrade happened,
// reuse this muxed connection
this.swarm.on('peer-mux-established', (peerInfo) => {
Expand All @@ -56,6 +54,8 @@ class Node extends EventEmitter {
this.swarm.on('peer-mux-closed', (peerInfo) => {
this.emit('peer:disconnect', peerInfo)
})

this.modules.transport.push(new Circuit(this.swarm, _options.relay))
}

// Attach crypto channels
Expand Down Expand Up @@ -171,7 +171,7 @@ class Node extends EventEmitter {
this.swarm.transport.add(
transport.tag || transport.constructor.name, transport)
} else if (transport.constructor &&
transport.constructor.name === 'WebSockets') {
transport.constructor.name === 'WebSockets') {
// TODO find a cleaner way to signal that a transport is always
// used for dialing, even if no listener
ws = transport
Expand Down
Loading

0 comments on commit 82a86ad

Please sign in to comment.