From 90c00443945ee30f68f8f252931c6a3cabae3b91 Mon Sep 17 00:00:00 2001 From: jMyles Date: Fri, 29 Jun 2018 19:15:56 -0700 Subject: [PATCH] There's really no point to specifying REST details - if you want to learn from a specific node, just make it your next teacher. --- nucypher/characters.py | 22 ++++++++++++---------- tests/network/test_network_actors.py | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/nucypher/characters.py b/nucypher/characters.py index 397bd6fed..600394757 100644 --- a/nucypher/characters.py +++ b/nucypher/characters.py @@ -325,20 +325,21 @@ class Character: if len(still_unknown) <= allow_missing: return False elif not self._learning_task.running: - raise self.NotEnoughUrsulas("We didn't discover any nodes because the learning loop isn't running. Start it with start_learning().") + raise self.NotEnoughUrsulas( + "We didn't discover any nodes because the learning loop isn't running. Start it with start_learning().") else: raise self.NotEnoughUrsulas("After {} seconds and {} rounds, didn't find these {} nodes: {}".format( timeout, rounds_undertaken, len(still_unknown), still_unknown)) - def learn_from_teacher_node(self, rest_address: str = None, port: int = None, eager=False): + def learn_from_teacher_node(self, eager=False): """ Sends a request to node_url to find out about known nodes. """ self._learning_round += 1 - if rest_address is None: - current_teacher = self.current_teacher_node() - rest_address = current_teacher.rest_interface.host - port = current_teacher.rest_interface.port + + current_teacher = self.current_teacher_node() + rest_address = current_teacher.rest_interface.host + port = current_teacher.rest_interface.port # TODO: Do we really want to try to learn about all these nodes instantly? Hearing this traffic might give insight to an attacker. response = self.network_middleware.get_nodes_via_rest(rest_address, @@ -362,10 +363,11 @@ class Character: if eager: ursula = Ursula.from_rest_url(network_middleware=self.network_middleware, - host=rest_info.host, - port=rest_info.port) - - self.remember_node(node) + host=node.rest_interface.host, + port=node.rest_interface.port) + self.remember_node(ursula) + else: + self.remember_node(node) else: message = "Suspicious Activity: Discovered node with bad signature: {}. " \ diff --git a/tests/network/test_network_actors.py b/tests/network/test_network_actors.py index 91c245fba..1eceaed7c 100644 --- a/tests/network/test_network_actors.py +++ b/tests/network/test_network_actors.py @@ -59,7 +59,7 @@ def test_alice_finds_ursula_via_rest(alice, ursulas): some_ursula_interface = ursulas.pop().rest_interface - new_nodes = alice.learn_from_teacher_node(rest_address=some_ursula_interface.host, port=some_ursula_interface.port) + new_nodes = alice.learn_from_teacher_node() assert len(new_nodes) == len(ursulas) for ursula in ursulas: