From 65ed2c7ceed24e1665ea5d92a66ca66c8c60d046 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Sun, 16 Feb 2020 09:53:33 -0600 Subject: [PATCH] make code more robust --- libp2p/muxers/muxer.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libp2p/muxers/muxer.nim b/libp2p/muxers/muxer.nim index bebd19fd9..4b2a71d1a 100644 --- a/libp2p/muxers/muxer.nim +++ b/libp2p/muxers/muxer.nim @@ -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