mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-18 14:44:21 +01:00
Additional bug-fixing
This commit is contained in:
@@ -9,8 +9,8 @@ class Builder:
|
|||||||
appointments = {}
|
appointments = {}
|
||||||
locator_uuid_map = {}
|
locator_uuid_map = {}
|
||||||
|
|
||||||
for uuid, appointment_data in appointments_data.items():
|
for uuid, data in appointments_data.items():
|
||||||
appointment = Appointment.from_dict(appointment_data)
|
appointment = Appointment.from_dict(data)
|
||||||
appointments[uuid] = appointment
|
appointments[uuid] = appointment
|
||||||
|
|
||||||
if appointment.locator in locator_uuid_map:
|
if appointment.locator in locator_uuid_map:
|
||||||
@@ -26,8 +26,8 @@ class Builder:
|
|||||||
jobs = {}
|
jobs = {}
|
||||||
tx_job_map = {}
|
tx_job_map = {}
|
||||||
|
|
||||||
for uuid, job_data in jobs_data.items():
|
for uuid, data in jobs_data.items():
|
||||||
job = Job.from_dict(jobs_data)
|
job = Job.from_dict(data)
|
||||||
jobs[uuid] = job
|
jobs[uuid] = job
|
||||||
|
|
||||||
if job.justice_txid in tx_job_map:
|
if job.justice_txid in tx_job_map:
|
||||||
|
|||||||
@@ -29,20 +29,23 @@ class Job:
|
|||||||
self.locator = sha256(unhexlify(dispute_txid)).hexdigest()
|
self.locator = sha256(unhexlify(dispute_txid)).hexdigest()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, jobs_data):
|
def from_dict(cls, job_data):
|
||||||
dispute_txid = jobs_data.get("dispute_txid")
|
dispute_txid = job_data.get("dispute_txid")
|
||||||
justice_txid = jobs_data.get("justice_txid")
|
justice_txid = job_data.get("justice_txid")
|
||||||
justice_rawtx = jobs_data.get("justice_rawtx")
|
justice_rawtx = job_data.get("justice_rawtx")
|
||||||
appointment_end = jobs_data.get("appointment_end")
|
appointment_end = job_data.get("appointment_end")
|
||||||
|
|
||||||
if all([dispute_txid, justice_txid, justice_rawtx, appointment_end]) is not None:
|
if all(v is not None for v in [dispute_txid, justice_txid, justice_rawtx, appointment_end]):
|
||||||
job = cls(dispute_txid, justice_txid, justice_rawtx, appointment_end)
|
job = cls(dispute_txid, justice_txid, justice_rawtx, appointment_end)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValueError("Wrong job data, some fields are missing")
|
raise ValueError("Wrong job data, some fields are missing")
|
||||||
|
|
||||||
|
return job
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
job = {"locator": self.locator, "justice_rawtx": self.justice_rawtx, "appointment_end": self.appointment_end}
|
job = {"locator": self.locator, "dispute_txid": self.dispute_txid, "justice_txid": self.justice_txid,
|
||||||
|
"justice_rawtx": self.justice_rawtx, "appointment_end": self.appointment_end}
|
||||||
|
|
||||||
return job
|
return job
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user