@@ -103,9 +103,12 @@ module.exports = function dial (swarm) {
103
103
nextMuxer ( muxers . shift ( ) )
104
104
105
105
function nextMuxer ( key ) {
106
- var msI = new multistream . Interactive ( )
107
- msI . handle ( conn , function ( ) {
108
- msI . select ( key , ( err , conn ) => {
106
+ const ms = new multistream . Dialer ( )
107
+ ms . handle ( conn , ( err ) => {
108
+ if ( err ) {
109
+ return callback ( new Error ( 'multistream not supported' ) )
110
+ }
111
+ ms . select ( key , ( err , conn ) => {
109
112
if ( err ) {
110
113
if ( muxers . length === 0 ) {
111
114
cb ( new Error ( 'could not upgrade to stream muxing' ) )
@@ -144,9 +147,12 @@ module.exports = function dial (swarm) {
144
147
}
145
148
146
149
function protocolHandshake ( conn , protocol , cb ) {
147
- var msI = new multistream . Interactive ( )
148
- msI . handle ( conn , function ( ) {
149
- msI . select ( protocol , ( err , conn ) => {
150
+ const ms = new multistream . Dialer ( )
151
+ ms . handle ( conn , ( err ) => {
152
+ if ( err ) {
153
+ return callback ( err )
154
+ }
155
+ ms . select ( protocol , ( err , conn ) => {
150
156
if ( err ) {
151
157
return callback ( err )
152
158
}
0 commit comments