mirror of
https://github.com/vacp2p/nim-libp2p-experimental.git
synced 2025-01-13 11:54:16 +00:00
make code more robust
This commit is contained in:
parent
9023bf786d
commit
65ed2c7cee
@ -46,11 +46,11 @@ proc newMuxerProvider*(creator: MuxerConstructor, codec: string): MuxerProvider
|
||||
method init(c: MuxerProvider) =
|
||||
proc handler(conn: Connection, proto: string) {.async, gcsafe, closure.} =
|
||||
let muxer = c.newMuxer(conn)
|
||||
var handlerFut: Future[void] = newFuture[void]()
|
||||
if not isNil(c.muxerHandler):
|
||||
handlerFut = c.muxerHandler(muxer)
|
||||
var handlerFut = if not isNil(c.muxerHandler):
|
||||
c.muxerHandler(muxer)
|
||||
else:
|
||||
handlerFut.complete()
|
||||
var dummyFut = newFuture[void]()
|
||||
dummyFut.complete(); dummyFut
|
||||
|
||||
if not isNil(c.streamHandler):
|
||||
muxer.streamHandler = c.streamHandler
|
||||
|
Loading…
x
Reference in New Issue
Block a user