fix: don't call conn handler on dials

This commit is contained in:
Dmitriy Ryajov 2019-09-05 09:20:05 -06:00
parent 0f52a6e798
commit 60245a065d
1 changed files with 8 additions and 6 deletions

View File

@ -17,9 +17,11 @@ type TcpTransport* = ref object of Transport
proc connHandler*(t: Transport,
server: StreamServer,
client: StreamTransport):
client: StreamTransport,
initiator: bool = false):
Future[Connection] {.async, gcsafe.} =
let conn: Connection = newConnection(newChronosStream(server, client))
if not initiator:
let handlerFut = if t.handler == nil: nil else: t.handler(conn)
let connHolder: ConnHolder = ConnHolder(connection: conn,
connFuture: handlerFut)
@ -61,6 +63,6 @@ method dial*(t: TcpTransport,
Future[Connection] {.async, gcsafe.} =
## dial a peer
let client: StreamTransport = await connect(address)
result = await t.connHandler(t.server, client)
result = await t.connHandler(t.server, client, true)
method handles*(t: TcpTransport, address: MultiAddress): bool {.gcsafe.} = true