def terminate_peer(self, peer: Peer): peer.terminate() del self.peers[peer.their_id] del self.peer_tasks[peer.their_id] self.connected_addrs.remove((peer.host, peer.port)) self.peer_count -= 1