address review comments

This commit is contained in:
Dmitriy Ryajov 2020-02-21 08:25:09 -06:00
parent fbcef69891
commit 6a7f9f058c
1 changed files with 8 additions and 5 deletions

View File

@ -145,7 +145,6 @@ proc cleanupConn(s: Switch, conn: Connection) {.async, gcsafe.} =
await s.connections[id].close()
s.connections.del(id)
if id in s.dialedPubSubPeers:
s.dialedPubSubPeers.excl(id)
# TODO: Investigate cleanupConn() always called twice for one peer.
@ -222,7 +221,11 @@ proc dial*(s: Switch,
for a in peer.addrs: # for each address
if t.handles(a): # check if it can dial it
trace "Dialing address", address = $a
try:
conn = await t.dial(a)
except CatchableError as exc:
trace "couldn't dial peer, transport failed", exc = exc.msg, address = a
continue
# make sure to assign the peer to the connection
conn.peerInfo = peer
conn = await s.upgradeOutgoing(conn)
@ -307,7 +310,7 @@ proc subscribeToPeer(s: Switch, peerInfo: PeerInfo) {.async, gcsafe.} =
let conn = await s.dial(peerInfo, s.pubSub.get().codec)
await s.pubSub.get().subscribeToPeer(conn)
except CatchableError as exc:
trace "unable to initiate pubsub", exc = exc.msg
warn "unable to initiate pubsub", exc = exc.msg
s.dialedPubSubPeers.excl(peerInfo.id)
proc subscribe*(s: Switch, topic: string, handler: TopicHandler): Future[void] {.gcsafe.} =