This commit is contained in:
Tanguy 2022-12-23 13:49:58 +01:00
parent 6e2c173848
commit a818dfaf59
No known key found for this signature in database
GPG Key ID: 7DD8EC6B6CE6C45E
1 changed files with 10 additions and 8 deletions

View File

@ -71,7 +71,7 @@ proc mux*(
# install stream handler
muxer.streamHandler = self.streamHandler
self.connManager.storeConn(conn)
let handler = muxer.handle()
try:
await self.identify(muxer)
@ -81,8 +81,10 @@ proc mux*(
# loop
debug "Could not identify connection", conn, msg = exc.msg
self.connManager.storeConn(conn)
# store it in muxed connections if we have a peer for it
self.connManager.storeMuxer(muxer, muxer.handle()) # store muxer and start read loop
self.connManager.storeMuxer(muxer, handler) # store muxer and start read loop
return muxer
@ -174,12 +176,6 @@ proc muxerHandler(
let
conn = muxer.connection
# store incoming connection
self.connManager.storeConn(conn)
# store muxer and muxed connection
self.connManager.storeMuxer(muxer)
try:
await self.identify(muxer)
when defined(libp2p_agents_metrics):
@ -203,6 +199,12 @@ proc muxerHandler(
await muxer.close()
trace "Exception in muxer handler", conn, msg = exc.msg
# store incoming connection
self.connManager.storeConn(conn)
# store muxer and muxed connection
self.connManager.storeMuxer(muxer)
proc new*(
T: type MuxedUpgrade,
identity: Identify,