From 92864f6f1529d1d3ffdc43cb0fea994df90cfd16 Mon Sep 17 00:00:00 2001 From: Jonathan Zernik Date: Mon, 20 Sep 2021 21:48:03 -0700 Subject: [PATCH] Make add and remove methods of connection manager private (#1372) --- squeaknode/network/connection_manager.py | 10 +++++----- squeaknode/network/peer_client.py | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/squeaknode/network/connection_manager.py b/squeaknode/network/connection_manager.py index 18ab18bd..a835820e 100644 --- a/squeaknode/network/connection_manager.py +++ b/squeaknode/network/connection_manager.py @@ -77,7 +77,7 @@ class ConnectionManager(object): logger.debug("Doing handshake.") connection.handshake() logger.debug("Adding peer.") - self.add_peer(peer) + self._add_peer(peer) result_queue.put( ConnectPeerResult.from_success(peer.remote_address)) logger.debug("Yielding connection.") @@ -87,7 +87,7 @@ class ConnectionManager(object): raise finally: logger.debug("Removing peer.") - self.remove_peer(peer) + self._remove_peer(peer) peer.stop() @property @@ -114,7 +114,7 @@ class ConnectionManager(object): return True return False - def add_peer(self, peer: Peer): + def _add_peer(self, peer: Peer): """Add a peer. """ with self.peers_lock: @@ -130,8 +130,8 @@ class ConnectionManager(object): logger.debug('Added peer {}'.format(peer)) self.on_peers_changed() - def remove_peer(self, peer: Peer): - """Add a peer. + def _remove_peer(self, peer: Peer): + """Remove a peer. """ with self.peers_lock: if not self.has_connection(peer.remote_address): diff --git a/squeaknode/network/peer_client.py b/squeaknode/network/peer_client.py index 5513cdc1..f006113a 100644 --- a/squeaknode/network/peer_client.py +++ b/squeaknode/network/peer_client.py @@ -54,7 +54,7 @@ class PeerClient(object): # Wait for connect result from the queue. connect_result = result_queue.get() - logger.info("connect_result: {}".format(connect_result)) + logger.debug("connect_result: {}".format(connect_result)) if connect_result.failure is not None: raise connect_result.failure @@ -62,7 +62,6 @@ class PeerClient(object): logger.info('Conecting to address: {}'.format(address)) try: peer_socket = self.get_socket() - logger.info('Trying to connect socket to {}'.format(address)) peer_socket.settimeout(SOCKET_CONNECT_TIMEOUT) peer_socket.connect(address) peer_socket.setblocking(True) @@ -72,7 +71,7 @@ class PeerClient(object): result_queue, ) except Exception as e: - logger.exception('Failed to make connection to {}'.format(address)) + logger.exception('Failed to connect to {}'.format(address)) result_queue.put(ConnectPeerResult.from_failure(e)) def handle_connection(