don't check if peers have `sendConn` when disconnecting for bad scoring

This commit is contained in:
Giovanni Petrantoni 2021-02-22 10:04:02 +09:00
parent 51d8cd4ade
commit 922cd92f94
1 changed files with 6 additions and 7 deletions

View File

@ -82,13 +82,12 @@ proc disconnectPeer(g: GossipSub, peer: PubSubPeer) {.async.} =
else: else:
libp2p_gossipsub_bad_score_disconnection.inc(labelValues = ["unknown"]) libp2p_gossipsub_bad_score_disconnection.inc(labelValues = ["unknown"])
if peer.sendConn != nil: try:
try: await g.switch.disconnect(peer.peerId)
await g.switch.disconnect(peer.peerId) except CancelledError:
except CancelledError: raise
raise except CatchableError as exc:
except CatchableError as exc: trace "Failed to close connection", peer, error = exc.name, msg = exc.msg
trace "Failed to close connection", peer, error = exc.name, msg = exc.msg
proc updateScores*(g: GossipSub) = # avoid async proc updateScores*(g: GossipSub) = # avoid async
trace "updating scores", peers = g.peers.len trace "updating scores", peers = g.peers.len