Ensuring that Enrico doesn't have to deal with known_node class.

pull/2175/head
jMyles 2020-07-14 16:09:14 -07:00
parent dcbd882a9c
commit 3d5c9d3560
2 changed files with 17 additions and 7 deletions

View File

@ -107,13 +107,10 @@ class Character(Learner):
if hasattr(self, '_interface_class'): # TODO: have argument about meaning of 'lawful'
# and whether maybe only Lawful characters have an interface
self.interface = self._interface_class(character=self)
if is_me:
if not known_node_class:
# Once in a while, in tests or demos, we init a plain Character who doesn't already know about its node class.
from nucypher.characters.lawful import Ursula
known_node_class = Ursula
# If we're federated only, we assume that all other nodes in our domain are as well.
known_node_class.set_federated_mode(federated_only)
self._set_known_node_class(known_node_class, federated_only)
else:
# What an awful hack. The last convulsions of #466.
# TODO: Anything else.
@ -340,6 +337,14 @@ class Character(Learner):
return cls(is_me=False, crypto_power=crypto_power, *args, **kwargs)
def _set_known_node_class(self, known_node_class, federated_only):
if not known_node_class:
# Once in a while, in tests or demos, we init a plain Character who doesn't already know about its node class.
from nucypher.characters.lawful import Ursula
known_node_class = Ursula
# If we're federated only, we assume that all other nodes in our domain are as well.
known_node_class.set_federated_mode(federated_only)
def store_metadata(self, filepath: str) -> str:
"""
Save this node to the disk.

View File

@ -1624,7 +1624,7 @@ class Enrico(Character):
# Encrico never uses the blockchain, hence federated_only)
kwargs['federated_only'] = True
kwargs['known_node_class'] = Ursula
kwargs['known_node_class'] = None
super().__init__(*args, **kwargs)
if controller:
@ -1658,6 +1658,11 @@ class Enrico(Character):
raise TypeError("This Enrico doesn't know which policy encrypting key he used. Oh well.")
return self._policy_pubkey
def _set_known_node_class(self, *args, **kwargs):
"""
Enrico doesn't init nodes, so it doesn't care what class they are.
"""
def make_web_controller(drone_enrico, crash_on_error: bool = False):
app_name = bytes(drone_enrico.stamp).hex()[:6]