parent
ee281310c0
commit
35ff99829e
|
@ -145,7 +145,7 @@ proc handle*(m: MultistreamSelect, conn: Connection) {.async, gcsafe.} =
|
|||
await conn.writeLp((h.proto & "\n"))
|
||||
await h.protocol.handler(conn, ms)
|
||||
return
|
||||
warn "no handlers for ", protocol = ms
|
||||
debug "no handlers for ", protocol = ms
|
||||
await conn.write(Na)
|
||||
except CatchableError as exc:
|
||||
trace "exception in multistream", exc = exc.msg
|
||||
|
|
|
@ -112,10 +112,15 @@ proc newIdentify*(peerInfo: PeerInfo): Identify =
|
|||
|
||||
method init*(p: Identify) =
|
||||
proc handle(conn: Connection, proto: string) {.async, gcsafe, closure.} =
|
||||
try:
|
||||
try:
|
||||
trace "handling identify request"
|
||||
var pb = encodeMsg(p.peerInfo, await conn.getObservedAddrs())
|
||||
await conn.writeLp(pb.buffer)
|
||||
# await conn.close() #TODO: investigate why this breaks
|
||||
finally:
|
||||
await conn.close()
|
||||
except CatchableError as exc:
|
||||
trace "exception in identify handler", exc = exc.msg
|
||||
|
||||
p.handler = handle
|
||||
p.codec = IdentifyCodec
|
||||
|
|
|
@ -110,6 +110,8 @@ proc mux(s: Switch, conn: Connection): Future[void] {.async, gcsafe.} =
|
|||
|
||||
# new stream for identify
|
||||
var stream = await muxer.newStream()
|
||||
# call muxer handler, this should
|
||||
# not end until muxer ends
|
||||
let handlerFut = muxer.handle()
|
||||
|
||||
# add muxer handler cleanup proc
|
||||
|
@ -117,10 +119,11 @@ proc mux(s: Switch, conn: Connection): Future[void] {.async, gcsafe.} =
|
|||
trace "muxer handler completed for peer",
|
||||
peer = conn.peerInfo.id
|
||||
|
||||
try:
|
||||
# do identify first, so that we have a
|
||||
# PeerInfo in case we didn't before
|
||||
conn.peerInfo = await s.identify(stream)
|
||||
|
||||
finally:
|
||||
await stream.close() # close identify stream
|
||||
|
||||
trace "connection's peerInfo", peerInfo = $conn.peerInfo
|
||||
|
|
Loading…
Reference in New Issue