From 3a06263f27552fa8f765779ad8a6049649839012 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Sat, 15 May 2021 20:24:18 +0300 Subject: [PATCH] Remove duplicate ports for connected nodes upon cleanup --- src/class_singleCleaner.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/class_singleCleaner.py b/src/class_singleCleaner.py index 4555b40f..6c390fdf 100644 --- a/src/class_singleCleaner.py +++ b/src/class_singleCleaner.py @@ -140,9 +140,22 @@ class singleCleaner(StoppableThread): if state.thisapp.daemon or not state.enableGUI: os._exit(1) - # inv/object tracking for connection in BMConnectionPool().connections(): - connection.clean() + connection.clean() # inv/object tracking + if not connection.fullyEstablished: + continue + self.logger.warning( + 'Cleaning up duplicate ports for host %s', + connection.destination.host) + # remove peers with same host and other ports from knownnodes + for stream in connection.streams: + for node in [ + node for node in knownnodes.knownNodes[stream] + if node.host == connection.destination.host + and node.port != connection.destination.port + ]: + self.logger.warning('port %s', node.port) + del knownnodes.knownNodes[stream][node] # discovery tracking exp = time.time() - singleCleaner.expireDiscoveredPeers