mirror of https://github.com/nucypher/nucypher.git
WorkOrder.tasks is now a dict, keyed by Capsule.
parent
234db351b6
commit
d5b74ab5a9
|
@ -648,9 +648,7 @@ class Bob(Character):
|
|||
else:
|
||||
cfrags = self.network_middleware.reencrypt(work_order)
|
||||
|
||||
def get_reencrypted_cfrags(self, work_order):
|
||||
cfrags = self.network_middleware.reencrypt(work_order)
|
||||
for task in work_order.tasks:
|
||||
for task in work_order.tasks.values():
|
||||
# TODO: Maybe just update the work order here instead of setting it anew.
|
||||
work_orders_by_ursula = self._saved_work_orders[work_order.ursula.checksum_address]
|
||||
work_orders_by_ursula[task.capsule] = work_order
|
||||
|
|
|
@ -293,7 +293,7 @@ class WorkOrder:
|
|||
if ursula._stamp_has_valid_signature_by_worker():
|
||||
ursula_identity_evidence = ursula.decentralized_identity_evidence
|
||||
|
||||
tasks, tasks_bytes = [], []
|
||||
tasks, tasks_bytes = {}, []
|
||||
for capsule in capsules:
|
||||
if alice_verifying_key != capsule.get_correctness_keys()["verifying"]:
|
||||
raise ValueError("Capsules in this work order are inconsistent.")
|
||||
|
@ -301,7 +301,7 @@ class WorkOrder:
|
|||
task = cls.Task(capsule, signature=None)
|
||||
specification = task.get_specification(ursula.stamp, alice_address, blockhash, ursula_identity_evidence)
|
||||
task.signature = bob.stamp(specification)
|
||||
tasks.append(task)
|
||||
tasks[capsule] = task
|
||||
tasks_bytes.append(bytes(task))
|
||||
|
||||
# TODO: What's the goal of the receipt? Should it include only the capsules?
|
||||
|
@ -356,7 +356,7 @@ class WorkOrder:
|
|||
receipt_signature=signature)
|
||||
|
||||
def payload(self):
|
||||
tasks_bytes = [bytes(item) for item in self.tasks]
|
||||
tasks_bytes = [bytes(item) for item in self.tasks.values()]
|
||||
payload_elements = msgpack.dumps((tasks_bytes, self.blockhash))
|
||||
return bytes(self.receipt_signature) + self.bob.stamp + payload_elements
|
||||
|
||||
|
@ -368,7 +368,7 @@ class WorkOrder:
|
|||
|
||||
ursula_verifying_key = self.ursula.stamp.as_umbral_pubkey()
|
||||
|
||||
for task, (cfrag, cfrag_signature) in zip(self.tasks, cfrags_and_signatures):
|
||||
for task, (cfrag, cfrag_signature) in zip(self.tasks.values(), cfrags_and_signatures):
|
||||
# Validate re-encryption metadata
|
||||
metadata_input = bytes(task.signature)
|
||||
metadata_as_signature = Signature.from_bytes(cfrag.proof.metadata)
|
||||
|
@ -383,7 +383,7 @@ class WorkOrder:
|
|||
raise InvalidSignature(f"{cfrag} is not properly signed by Ursula.")
|
||||
# TODO: Instead of raising, we should do something (#957)
|
||||
|
||||
for task, (cfrag, cfrag_signature) in zip(self.tasks, cfrags_and_signatures):
|
||||
for task, (cfrag, cfrag_signature) in zip(self.tasks.values(), cfrags_and_signatures):
|
||||
task.attach_work_result(cfrag, cfrag_signature)
|
||||
|
||||
self.completed = maya.now()
|
||||
|
|
Loading…
Reference in New Issue