From 922cd92f94cfa61229433c367c68a62524beab31 Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni <7008900+sinkingsugar@users.noreply.github.com> Date: Mon, 22 Feb 2021 10:04:02 +0900 Subject: [PATCH] don't check if peers have `sendConn` when disconnecting for bad scoring --- libp2p/protocols/pubsub/gossipsub/scoring.nim | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libp2p/protocols/pubsub/gossipsub/scoring.nim b/libp2p/protocols/pubsub/gossipsub/scoring.nim index 43638ca..53865f4 100644 --- a/libp2p/protocols/pubsub/gossipsub/scoring.nim +++ b/libp2p/protocols/pubsub/gossipsub/scoring.nim @@ -82,13 +82,12 @@ proc disconnectPeer(g: GossipSub, peer: PubSubPeer) {.async.} = else: libp2p_gossipsub_bad_score_disconnection.inc(labelValues = ["unknown"]) - if peer.sendConn != nil: - try: - await g.switch.disconnect(peer.peerId) - except CancelledError: - raise - except CatchableError as exc: - trace "Failed to close connection", peer, error = exc.name, msg = exc.msg + try: + await g.switch.disconnect(peer.peerId) + except CancelledError: + raise + except CatchableError as exc: + trace "Failed to close connection", peer, error = exc.name, msg = exc.msg proc updateScores*(g: GossipSub) = # avoid async trace "updating scores", peers = g.peers.len