From bdb09c2d00d2bdbb7ad6ec6076a92f99c246abda Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Mon, 29 Jul 2019 14:37:56 +0300 Subject: [PATCH] Ignore self node in connectionchooser.chooseConnection() --- src/network/connectionchooser.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/network/connectionchooser.py b/src/network/connectionchooser.py index 4b1565a2..53ce30b7 100644 --- a/src/network/connectionchooser.py +++ b/src/network/connectionchooser.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-branches import random # nosec import knownnodes @@ -38,7 +39,10 @@ def chooseConnection(stream): for _ in range(50): peer = random.choice(knownnodes.knownNodes[stream].keys()) try: - rating = knownnodes.knownNodes[stream][peer]['rating'] + peer_info = knownnodes.knownNodes[stream][peer] + if peer_info.get('self'): + continue + rating = peer_info["rating"] except TypeError: logger.warning('Error in %s', peer) rating = 0