Moving seednode loading logic inward.

pull/2140/head
jMyles 2020-06-23 02:32:01 -07:00
parent 4ca6688a8d
commit 3c58a0ce60
3 changed files with 21 additions and 6 deletions

View File

@ -238,12 +238,28 @@ class Learner:
def load_seednodes(self, read_storage: bool = True, retry_attempts: int = 3):
"""
Engage known nodes from storages and pre-fetch hardcoded seednode certificates for node learning.
TODO: Dehydrate this with nucypher.utilities.seednodes.load_seednodes
"""
if self.done_seeding:
self.log.debug("Already done seeding; won't try again.")
return
from nucypher.utilities.seednodes import aggregate_seednode_uris # TODO: Ugh.
# teacher_uris = aggregate_seednode_uris(domains=self.learning_domains)
canonical_sage_uris = self.network_middleware.TEACHER_NODES.get(tuple(self.learning_domains)[0], ()) # TODO: Are we done with multiple domains?
# TODO: Is this better as a sprout?
from nucypher.characters.lawful import Ursula
############################
for uri in canonical_sage_uris:
# Not catching any errors here; we want to fail fast if there are bad hardcoded teachers.
# This is essentially an __active-fire__ if it's anything but a fleeting one-off.
sage_node = Ursula.from_teacher_uri(teacher_uri=uri,
min_stake=0, # TODO: Where to get this?
federated_only=self.federated_only,
network_middleware=self.network_middleware,
registry=self.registry)
self.remember_node(sage_node)
################
for seednode_metadata in self._seed_nodes:
self.log.debug(
@ -275,7 +291,7 @@ class Learner:
def read_nodes_from_storage(self) -> None:
stored_nodes = self.node_storage.all(federated_only=self.federated_only) # TODO: #466
for node in stored_nodes:
self.remember_node(node)
self.remember_node(node) # TODO: Validity status 1866
def remember_node(self,
node,

View File

@ -33,8 +33,6 @@ from nucypher.cli.literature import (
from nucypher.config.constants import DEFAULT_CONFIG_ROOT
from nucypher.network.exceptions import NodeSeemsToBeDown
from nucypher.network.middleware import RestMiddleware
from nucypher.network.nodes import Teacher
from nucypher.network.teachers import TEACHER_NODES
def load_static_nodes(domains: Set[str], filepath: Optional[str] = None) -> Dict[str, 'Ursula']:
@ -118,7 +116,7 @@ def load_seednodes(emitter,
except NodeSeemsToBeDown:
emitter.message(UNREADABLE_SEEDNODE_ADVISORY.format(uri=uri))
continue
except Teacher.NotStaking:
except Ursula.NotStaking:
emitter.message(SEEDNODE_NOT_STAKING_WARNING.format(uri=uri))
continue
teacher_nodes.append(teacher_node)

View File

@ -213,6 +213,7 @@ def _cli_lifecycle(click_runner,
bob_configuration_file_location = os.path.join(bob_config_root, BobConfiguration.generate_filename())
bob_view_args = ('bob', 'public-keys',
'--json-ipc',
'--mock-networking', # TODO: It's absurd for this public-keys command to connect at all. 1710
'--config-file', bob_configuration_file_location)
bob_view_result = click_runner.invoke(nucypher_cli, bob_view_args, catch_exceptions=False, env=envvars)
@ -226,7 +227,7 @@ def _cli_lifecycle(click_runner,
side_channel.save_bob_public_keys(bob_public_keys)
"""
Scene 3: Alice derives a policy keypair, and saves it's public key to a sidechannel.
Scene 3: Alice derives a policy keypair, and saves its public key to a sidechannel.
"""
random_label = random_policy_label.decode() # Unicode string