Pass-through caught MinerAgent.sample's exception message when Alice recruits Ursulas from the blockchain

pull/447/head
Kieran Prasch 2018-09-24 14:35:47 -07:00
parent d02a8bc0bf
commit 922eb9ab5a
2 changed files with 10 additions and 12 deletions

View File

@ -279,8 +279,7 @@ class PolicyAuthor(NucypherTokenActor):
self.miner_agent = policy_agent.miner_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]:
"""

View File

@ -173,17 +173,16 @@ class BlockchainPolicy(Policy):
target_sample_quantity = self.n - len(handpicked_ursulas)
selected_addresses = set() # type: set
try: # Sample by reading from the Blockchain
actual_sample_quantity = math.ceil(target_sample_quantity * ADDITIONAL_URSULAS)
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)
candidates = handpicked_ursulas