Skip to content
This repository was archived by the owner on Aug 23, 2019. It is now read-only.

Commit bff0a8b

Browse files
dryajovJacob Heun
authored andcommitted
fix: no stats on multistream proto dial
1 parent e9b158d commit bff0a8b

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/dial.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class Dialer {
218218
}
219219

220220
if (err) {
221+
log('muxer upgrade failed with error', err)
221222
// couldn't upgrade to Muxer, it is ok, use the existing connection
222223
return callback(null, connection)
223224
}
@@ -257,7 +258,7 @@ class Dialer {
257258
// - add incomming new streams to connHandler
258259
const nextMuxer = (key) => {
259260
log('selecting %s', key)
260-
selectSafe(msDialer, key, (err, conn) => {
261+
selectSafe(msDialer, key, (err, _conn) => {
261262
if (err) {
262263
if (muxers.length === 0) {
263264
return callback(new Error('could not upgrade to stream muxing'))
@@ -266,6 +267,9 @@ class Dialer {
266267
return nextMuxer(muxers.shift())
267268
}
268269

270+
// observe muxed connections
271+
const conn = observeConnection(null, key, _conn, this.switch.observer)
272+
269273
const muxedConn = this.switch.muxers[key].dialer(conn)
270274
this.switch.muxedConns[b58Id] = {
271275
muxer: muxedConn
@@ -404,7 +408,8 @@ class Dialer {
404408
return callback(err)
405409
}
406410

407-
selectSafe(msDialer, this.protocol, (err, conn) => {
411+
selectSafe(msDialer, this.protocol, (err, _conn) => {
412+
const conn = observeConnection(null, this.protocol, _conn, this.switch.observer)
408413
callback(err, conn)
409414
}, callback)
410415
}, callback)

src/protocol-muxer.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
const multistream = require('multistream-select')
44
const observeConn = require('./observe-connection')
55

6+
const debug = require('debug')
7+
const log = debug('libp2p:switch:protocol-muxer')
8+
69
module.exports = function protocolMuxer (protocols, observer) {
710
return (transport) => (_parentConn) => {
8-
const parentConn = observeConn(transport, null, _parentConn, observer)
11+
const parentConn = transport
12+
? observeConn(transport, null, _parentConn, observer)
13+
: _parentConn
14+
915
const ms = new multistream.Listener()
1016

1117
Object.keys(protocols).forEach((protocol) => {
@@ -14,6 +20,7 @@ module.exports = function protocolMuxer (protocols, observer) {
1420
}
1521

1622
const handler = (protocolName, _conn) => {
23+
log(`registering handler with protocol ${protocolName}`)
1724
const protocol = protocols[protocolName]
1825
if (protocol) {
1926
const handlerFunc = protocol && protocol.handlerFunc

0 commit comments

Comments
 (0)