set mplex channel peerInfo correctly

This commit is contained in:
Dmitriy Ryajov 2019-09-11 13:04:27 -06:00
parent 4f158d4e83
commit 67e10d0747
1 changed files with 4 additions and 1 deletions

View File

@ -80,7 +80,9 @@ method handle*(m: Mplex) {.async, gcsafe.} =
channel = await m.newStreamInternal(false, id, name) channel = await m.newStreamInternal(false, id, name)
debug "handle: created channel ", id = id, name = name debug "handle: created channel ", id = id, name = name
if not isNil(m.streamHandler): if not isNil(m.streamHandler):
let handlerFut = m.streamHandler(newConnection(channel)) let stream = newConnection(channel)
stream.peerInfo = m.connection.peerInfo
let handlerFut = m.streamHandler(newConnection(stream))
# TODO: don't use a closure? # TODO: don't use a closure?
# channel cleanup routine # channel cleanup routine
@ -121,6 +123,7 @@ method newStream*(m: Mplex, name: string = ""): Future[Connection] {.async, gcsa
let channel = await m.newStreamInternal() let channel = await m.newStreamInternal()
await m.connection.writeMsg(channel.id, MessageType.New, name) await m.connection.writeMsg(channel.id, MessageType.New, name)
result = newConnection(channel) result = newConnection(channel)
result.peerInfo = m.connection.peerInfo
method close*(m: Mplex) {.async, gcsafe.} = method close*(m: Mplex) {.async, gcsafe.} =
await allFutures(@[allFutures(toSeq(m.remote.values).mapIt(it.close())), await allFutures(@[allFutures(toSeq(m.remote.values).mapIt(it.close())),