mirror of https://github.com/nucypher/nucypher.git
Pass-through caught MinerAgent.sample's exception message when Alice recruits Ursulas from the blockchain
parent
d02a8bc0bf
commit
922eb9ab5a
|
@ -279,8 +279,7 @@ class PolicyAuthor(NucypherTokenActor):
|
||||||
self.miner_agent = policy_agent.miner_agent
|
self.miner_agent = policy_agent.miner_agent
|
||||||
|
|
||||||
super().__init__(token_agent=self.policy_agent.token_agent,
|
super().__init__(token_agent=self.policy_agent.token_agent,
|
||||||
checksum_address=checksum_address,
|
checksum_address=checksum_address)
|
||||||
)
|
|
||||||
|
|
||||||
def recruit(self, quantity: int, **options) -> List[str]:
|
def recruit(self, quantity: int, **options) -> List[str]:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -173,17 +173,16 @@ class BlockchainPolicy(Policy):
|
||||||
target_sample_quantity = self.n - len(handpicked_ursulas)
|
target_sample_quantity = self.n - len(handpicked_ursulas)
|
||||||
|
|
||||||
selected_addresses = set() # type: set
|
selected_addresses = set() # type: set
|
||||||
try: # Sample by reading from the Blockchain
|
|
||||||
actual_sample_quantity = math.ceil(target_sample_quantity * ADDITIONAL_URSULAS)
|
actual_sample_quantity = math.ceil(target_sample_quantity * ADDITIONAL_URSULAS)
|
||||||
duration = int(calculate_period_duration(expiration))
|
duration = int(calculate_period_duration(expiration))
|
||||||
sampled_addresses = self.alice.recruit(quantity=actual_sample_quantity,
|
|
||||||
duration=duration)
|
|
||||||
except MinerAgent.NotEnoughMiners:
|
|
||||||
error = "Cannot create policy with {} arrangements."
|
|
||||||
raise self.NotEnoughBlockchainUrsulas(error.format(self.n))
|
|
||||||
else:
|
|
||||||
selected_addresses.update(sampled_addresses)
|
|
||||||
|
|
||||||
|
try: # Sample by reading from the Blockchain
|
||||||
|
sampled_addresses = self.alice.recruit(quantity=actual_sample_quantity, duration=duration)
|
||||||
|
except MinerAgent.NotEnoughMiners as e:
|
||||||
|
error = "Cannot create policy with {} arrangements: {}".format(target_sample_quantity, e)
|
||||||
|
raise self.NotEnoughBlockchainUrsulas(error)
|
||||||
|
|
||||||
|
selected_addresses.update(sampled_addresses)
|
||||||
found_ursulas = self.__find_ursulas(sampled_addresses, target_sample_quantity)
|
found_ursulas = self.__find_ursulas(sampled_addresses, target_sample_quantity)
|
||||||
|
|
||||||
candidates = handpicked_ursulas
|
candidates = handpicked_ursulas
|
||||||
|
|
Loading…
Reference in New Issue