mirror of https://github.com/nucypher/nucypher.git
Moving seednode loading logic inward.
parent
4ca6688a8d
commit
3c58a0ce60
|
@ -238,12 +238,28 @@ class Learner:
|
||||||
def load_seednodes(self, read_storage: bool = True, retry_attempts: int = 3):
|
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.
|
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:
|
if self.done_seeding:
|
||||||
self.log.debug("Already done seeding; won't try again.")
|
self.log.debug("Already done seeding; won't try again.")
|
||||||
return
|
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
|
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:
|
for seednode_metadata in self._seed_nodes:
|
||||||
|
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
|
@ -275,7 +291,7 @@ class Learner:
|
||||||
def read_nodes_from_storage(self) -> None:
|
def read_nodes_from_storage(self) -> None:
|
||||||
stored_nodes = self.node_storage.all(federated_only=self.federated_only) # TODO: #466
|
stored_nodes = self.node_storage.all(federated_only=self.federated_only) # TODO: #466
|
||||||
for node in stored_nodes:
|
for node in stored_nodes:
|
||||||
self.remember_node(node)
|
self.remember_node(node) # TODO: Validity status 1866
|
||||||
|
|
||||||
def remember_node(self,
|
def remember_node(self,
|
||||||
node,
|
node,
|
||||||
|
|
|
@ -33,8 +33,6 @@ from nucypher.cli.literature import (
|
||||||
from nucypher.config.constants import DEFAULT_CONFIG_ROOT
|
from nucypher.config.constants import DEFAULT_CONFIG_ROOT
|
||||||
from nucypher.network.exceptions import NodeSeemsToBeDown
|
from nucypher.network.exceptions import NodeSeemsToBeDown
|
||||||
from nucypher.network.middleware import RestMiddleware
|
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']:
|
def load_static_nodes(domains: Set[str], filepath: Optional[str] = None) -> Dict[str, 'Ursula']:
|
||||||
|
@ -118,7 +116,7 @@ def load_seednodes(emitter,
|
||||||
except NodeSeemsToBeDown:
|
except NodeSeemsToBeDown:
|
||||||
emitter.message(UNREADABLE_SEEDNODE_ADVISORY.format(uri=uri))
|
emitter.message(UNREADABLE_SEEDNODE_ADVISORY.format(uri=uri))
|
||||||
continue
|
continue
|
||||||
except Teacher.NotStaking:
|
except Ursula.NotStaking:
|
||||||
emitter.message(SEEDNODE_NOT_STAKING_WARNING.format(uri=uri))
|
emitter.message(SEEDNODE_NOT_STAKING_WARNING.format(uri=uri))
|
||||||
continue
|
continue
|
||||||
teacher_nodes.append(teacher_node)
|
teacher_nodes.append(teacher_node)
|
||||||
|
|
|
@ -213,6 +213,7 @@ def _cli_lifecycle(click_runner,
|
||||||
bob_configuration_file_location = os.path.join(bob_config_root, BobConfiguration.generate_filename())
|
bob_configuration_file_location = os.path.join(bob_config_root, BobConfiguration.generate_filename())
|
||||||
bob_view_args = ('bob', 'public-keys',
|
bob_view_args = ('bob', 'public-keys',
|
||||||
'--json-ipc',
|
'--json-ipc',
|
||||||
|
'--mock-networking', # TODO: It's absurd for this public-keys command to connect at all. 1710
|
||||||
'--config-file', bob_configuration_file_location)
|
'--config-file', bob_configuration_file_location)
|
||||||
|
|
||||||
bob_view_result = click_runner.invoke(nucypher_cli, bob_view_args, catch_exceptions=False, env=envvars)
|
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)
|
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
|
random_label = random_policy_label.decode() # Unicode string
|
||||||
|
|
Loading…
Reference in New Issue