mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-05-03 14:32:18 +00:00
clean the code a bit
This commit is contained in:
parent
14d11de201
commit
f08d407bf9
@ -53,8 +53,8 @@ function Swarm () {
|
|||||||
// attach multistream handlers to incoming streams
|
// attach multistream handlers to incoming streams
|
||||||
conn.on('stream', registerHandles)
|
conn.on('stream', registerHandles)
|
||||||
|
|
||||||
// IDENTIFY DOES THAT FOR US
|
// IDENTIFY DOES THAT FOR US
|
||||||
// conn.on('close', function () { delete self.connections[conn.peerId] })
|
// conn.on('close', function () { delete self.connections[conn.peerId] })
|
||||||
})
|
})
|
||||||
}).listen(self.port, ready)
|
}).listen(self.port, ready)
|
||||||
}
|
}
|
||||||
@ -63,10 +63,8 @@ function Swarm () {
|
|||||||
|
|
||||||
// open stream account for connection reuse
|
// open stream account for connection reuse
|
||||||
self.openStream = function (peer, protocol, cb) {
|
self.openStream = function (peer, protocol, cb) {
|
||||||
|
|
||||||
// If no connection open yet, open it
|
// If no connection open yet, open it
|
||||||
if (!self.connections[peer.id.toB58String()]) {
|
if (!self.connections[peer.id.toB58String()]) {
|
||||||
|
|
||||||
// Establish a socket with one of the addresses
|
// Establish a socket with one of the addresses
|
||||||
var socket
|
var socket
|
||||||
async.eachSeries(peer.multiaddrs, function (multiaddr, next) {
|
async.eachSeries(peer.multiaddrs, function (multiaddr, next) {
|
||||||
@ -85,7 +83,7 @@ function Swarm () {
|
|||||||
}, function done () {
|
}, function done () {
|
||||||
if (!socket) {
|
if (!socket) {
|
||||||
return cb(new Error('Not able to open a scoket with peer - ',
|
return cb(new Error('Not able to open a scoket with peer - ',
|
||||||
peer.id.toB58String()))
|
peer.id.toB58String()))
|
||||||
}
|
}
|
||||||
gotSocket(socket)
|
gotSocket(socket)
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user