mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-05-06 16:02:15 +00:00
fix: overwrite stream fields after handshake (#1305)
Instead of creating a new stream objects instead just overwrite the duplex fields with ones from the mss stream.
This commit is contained in:
parent
d63e08115b
commit
43b0418998
@ -9,7 +9,7 @@
|
|||||||
"@libp2p/delegated-content-routing": "^2.0.1",
|
"@libp2p/delegated-content-routing": "^2.0.1",
|
||||||
"@libp2p/delegated-peer-routing": "^2.0.1",
|
"@libp2p/delegated-peer-routing": "^2.0.1",
|
||||||
"@libp2p/kad-dht": "^3.0.0",
|
"@libp2p/kad-dht": "^3.0.0",
|
||||||
"@libp2p/mplex": "^5.0.0",
|
"@libp2p/mplex": "^5.2.1",
|
||||||
"@libp2p/webrtc-star": "^3.0.0",
|
"@libp2p/webrtc-star": "^3.0.0",
|
||||||
"@libp2p/websockets": "^3.0.0",
|
"@libp2p/websockets": "^3.0.0",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chainsafe/libp2p-noise": "^8.0.0",
|
"@chainsafe/libp2p-noise": "^8.0.0",
|
||||||
"@libp2p/bootstrap": "^2.0.0",
|
"@libp2p/bootstrap": "^2.0.0",
|
||||||
"@libp2p/mplex": "^5.0.0",
|
"@libp2p/mplex": "^5.2.1",
|
||||||
"@libp2p/webrtc-star": "^3.0.0",
|
"@libp2p/webrtc-star": "^3.0.0",
|
||||||
"@libp2p/websockets": "^3.0.0",
|
"@libp2p/websockets": "^3.0.0",
|
||||||
"libp2p": "../../"
|
"libp2p": "../../"
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
"@libp2p/webrtc-direct": "^2.0.0",
|
"@libp2p/webrtc-direct": "^2.0.0",
|
||||||
"@chainsafe/libp2p-noise": "^8.0.0",
|
"@chainsafe/libp2p-noise": "^8.0.0",
|
||||||
"@libp2p/bootstrap": "^2.0.0",
|
"@libp2p/bootstrap": "^2.0.0",
|
||||||
"@libp2p/mplex": "^5.0.0",
|
"@libp2p/mplex": "^5.2.1",
|
||||||
"libp2p": "../../",
|
"libp2p": "../../",
|
||||||
"wrtc": "^0.4.7"
|
"wrtc": "^0.4.7"
|
||||||
},
|
},
|
||||||
|
@ -180,7 +180,7 @@
|
|||||||
"@libp2p/interop": "^2.0.0",
|
"@libp2p/interop": "^2.0.0",
|
||||||
"@libp2p/kad-dht": "^3.0.4",
|
"@libp2p/kad-dht": "^3.0.4",
|
||||||
"@libp2p/mdns": "^3.0.0",
|
"@libp2p/mdns": "^3.0.0",
|
||||||
"@libp2p/mplex": "^5.0.0",
|
"@libp2p/mplex": "^5.2.1",
|
||||||
"@libp2p/pubsub": "^3.0.1",
|
"@libp2p/pubsub": "^3.0.1",
|
||||||
"@libp2p/tcp": "^3.0.5",
|
"@libp2p/tcp": "^3.0.5",
|
||||||
"@libp2p/topology": "^3.0.0",
|
"@libp2p/topology": "^3.0.0",
|
||||||
|
@ -440,20 +440,17 @@ export class DefaultUpgrader extends EventEmitter<UpgraderEvents> implements Upg
|
|||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
|
|
||||||
muxedStream.stat.protocol = protocol
|
|
||||||
|
|
||||||
// If a protocol stream has been successfully negotiated and is to be passed to the application,
|
// If a protocol stream has been successfully negotiated and is to be passed to the application,
|
||||||
// the peerstore should ensure that the peer is registered with that protocol
|
// the peerstore should ensure that the peer is registered with that protocol
|
||||||
this.components.getPeerStore().protoBook.add(remotePeer, [protocol]).catch(err => log.error(err))
|
this.components.getPeerStore().protoBook.add(remotePeer, [protocol]).catch(err => log.error(err))
|
||||||
|
|
||||||
return {
|
// after the handshake the returned stream can have early data so override
|
||||||
...muxedStream,
|
// the souce/sink
|
||||||
...stream,
|
muxedStream.source = stream.source
|
||||||
stat: {
|
muxedStream.sink = stream.sink
|
||||||
...muxedStream.stat,
|
muxedStream.stat.protocol = protocol
|
||||||
protocol
|
|
||||||
}
|
return muxedStream
|
||||||
}
|
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
log.error('could not create new stream', err)
|
log.error('could not create new stream', err)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user