mirror of https://github.com/nucypher/nucypher.git
Different map classes for different policy modes.
parent
f4fc313a45
commit
6e163a1ba0
|
@ -124,7 +124,6 @@ class BlockchainArrangement(Arrangement):
|
|||
expiration: maya.MayaDT,
|
||||
duration_periods: int,
|
||||
*args, **kwargs):
|
||||
|
||||
super().__init__(alice=alice, ursula=ursula, expiration=expiration, *args, **kwargs)
|
||||
|
||||
# The relationship exists between two addresses
|
||||
|
@ -254,7 +253,7 @@ class Policy(ABC):
|
|||
"""
|
||||
return keccak_digest(bytes(self.alice.stamp) + bytes(self.bob.stamp) + self.label)
|
||||
|
||||
def publish_treasure_map(self, network_middleware: RestMiddleware, blockchain_signer: Callable=None) -> dict:
|
||||
def publish_treasure_map(self, network_middleware: RestMiddleware, blockchain_signer: Callable = None) -> dict:
|
||||
self.treasure_map.prepare_for_publication(self.bob.public_keys(DecryptingPower),
|
||||
self.bob.public_keys(SigningPower),
|
||||
self.alice.stamp,
|
||||
|
@ -311,7 +310,6 @@ class Policy(ABC):
|
|||
return PolicyCredential(self.alice.stamp, self.label, self.expiration,
|
||||
self.public_key, treasure_map)
|
||||
|
||||
|
||||
def __assign_kfrags(self) -> Generator[Arrangement, None, None]:
|
||||
|
||||
if len(self._accepted_arrangements) < self.n:
|
||||
|
@ -356,7 +354,7 @@ class Policy(ABC):
|
|||
# OK, let's check: if two or more Ursulas claimed we didn't pay,
|
||||
# we need to re-evaulate our situation here.
|
||||
arrangement_statuses = [a.status for a in self._accepted_arrangements]
|
||||
number_of_claims_of_freeloading = sum(status==402 for status in arrangement_statuses)
|
||||
number_of_claims_of_freeloading = sum(status == 402 for status in arrangement_statuses)
|
||||
|
||||
if number_of_claims_of_freeloading > 2:
|
||||
raise self.alice.NotEnoughNodes # TODO: Clean this up and enable re-tries.
|
||||
|
@ -457,7 +455,7 @@ class Policy(ABC):
|
|||
accepted = len(self._accepted_arrangements)
|
||||
if accepted == self.n and not consider_everyone:
|
||||
try:
|
||||
spares = set(list(candidate_ursulas)[index+1::])
|
||||
spares = set(list(candidate_ursulas)[index + 1::])
|
||||
self._spare_candidates.update(spares)
|
||||
except IndexError:
|
||||
self._spare_candidates = set()
|
||||
|
@ -468,7 +466,6 @@ class Policy(ABC):
|
|||
|
||||
|
||||
class FederatedPolicy(Policy):
|
||||
|
||||
_arrangement_class = Arrangement
|
||||
from nucypher.policy.collections import TreasureMap as _treasure_map_class # TODO: Circular Import
|
||||
|
||||
|
@ -682,5 +679,6 @@ class BlockchainPolicy(Policy):
|
|||
label=self.label)
|
||||
# Sign the map.
|
||||
transacting_power = self.alice._crypto_power.power_ups(TransactingPower)
|
||||
self.publish_treasure_map(network_middleware=network_middleware, blockchain_signer=transacting_power.sign_message)
|
||||
self.publish_treasure_map(network_middleware=network_middleware,
|
||||
blockchain_signer=transacting_power.sign_message)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue