mirror of https://github.com/nucypher/nucypher.git
New concept for saving WorkOrders by Bob.
parent
fb5731fff4
commit
2b1ca0d0d9
|
@ -236,7 +236,7 @@ class Bob(Character):
|
|||
self._ursulas = {}
|
||||
if alice:
|
||||
self.alice = alice
|
||||
self._work_orders = {}
|
||||
self._saved_work_orders = {}
|
||||
|
||||
@property
|
||||
def alice(self):
|
||||
|
@ -285,17 +285,20 @@ class Bob(Character):
|
|||
# TODO: Perhaps instead of taking a policy_group, it makes more sense for Bob to reconstruct one with the TreasureMap. See #140.
|
||||
from nkms.policy.models import WorkOrder # Prevent circular import
|
||||
|
||||
existing_work_orders = self._work_orders.setdefault(pfrags, {})
|
||||
generated_work_orders = {}
|
||||
|
||||
for ursula_dht_key, ursula in self._ursulas.items():
|
||||
if ursula_dht_key in existing_work_orders:
|
||||
# TODO: This arguably doesn't make any sense in the case of a Challenge - we only care if *this* pFrag
|
||||
# has gone to *this* Ursula, not if *all these pFrags* have gone to this Ursula.
|
||||
continue
|
||||
else:
|
||||
work_order = WorkOrder.constructed_by_bob(policy_group.hrac(), pfrags, ursula_dht_key, self)
|
||||
existing_work_orders[ursula_dht_key] = generated_work_orders[ursula_dht_key] = work_order
|
||||
|
||||
completed_work_orders_for_this_ursula = self._saved_work_orders.setdefault(ursula_dht_key, [])
|
||||
|
||||
pfrags_to_include = []
|
||||
for pfrag in pfrags:
|
||||
if not pfrag in sum([wo.pfrags for wo in completed_work_orders_for_this_ursula], []): # TODO: This is inane - probably push it down into a WorkOrderHistory concept.
|
||||
pfrags_to_include.append(pfrag)
|
||||
|
||||
if pfrags_to_include:
|
||||
work_order = WorkOrder.constructed_by_bob(policy_group.hrac(), pfrags_to_include, ursula_dht_key, self)
|
||||
generated_work_orders[ursula_dht_key] = work_order
|
||||
|
||||
if num_ursulas is not None:
|
||||
if num_ursulas == len(generated_work_orders):
|
||||
|
|
Loading…
Reference in New Issue