mirror of https://github.com/vacp2p/nim-libp2p.git
address review comments
This commit is contained in:
parent
fbcef69891
commit
6a7f9f058c
|
@ -145,7 +145,6 @@ proc cleanupConn(s: Switch, conn: Connection) {.async, gcsafe.} =
|
||||||
await s.connections[id].close()
|
await s.connections[id].close()
|
||||||
s.connections.del(id)
|
s.connections.del(id)
|
||||||
|
|
||||||
if id in s.dialedPubSubPeers:
|
|
||||||
s.dialedPubSubPeers.excl(id)
|
s.dialedPubSubPeers.excl(id)
|
||||||
|
|
||||||
# TODO: Investigate cleanupConn() always called twice for one peer.
|
# 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
|
for a in peer.addrs: # for each address
|
||||||
if t.handles(a): # check if it can dial it
|
if t.handles(a): # check if it can dial it
|
||||||
trace "Dialing address", address = $a
|
trace "Dialing address", address = $a
|
||||||
|
try:
|
||||||
conn = await t.dial(a)
|
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
|
# make sure to assign the peer to the connection
|
||||||
conn.peerInfo = peer
|
conn.peerInfo = peer
|
||||||
conn = await s.upgradeOutgoing(conn)
|
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)
|
let conn = await s.dial(peerInfo, s.pubSub.get().codec)
|
||||||
await s.pubSub.get().subscribeToPeer(conn)
|
await s.pubSub.get().subscribeToPeer(conn)
|
||||||
except CatchableError as exc:
|
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)
|
s.dialedPubSubPeers.excl(peerInfo.id)
|
||||||
|
|
||||||
proc subscribe*(s: Switch, topic: string, handler: TopicHandler): Future[void] {.gcsafe.} =
|
proc subscribe*(s: Switch, topic: string, handler: TopicHandler): Future[void] {.gcsafe.} =
|
||||||
|
|
Loading…
Reference in New Issue