mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 22:24:23 +01:00
50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
from queue import Queue
|
|
|
|
from pisa.responder import Job
|
|
from pisa.appointment import Appointment
|
|
|
|
|
|
class Builder:
|
|
@staticmethod
|
|
def build_appointments(appointments_data):
|
|
appointments = {}
|
|
locator_uuid_map = {}
|
|
|
|
for uuid, data in appointments_data.items():
|
|
appointment = Appointment.from_dict(data)
|
|
appointments[uuid] = appointment
|
|
|
|
if appointment.locator in locator_uuid_map:
|
|
locator_uuid_map[appointment.locator].append(uuid)
|
|
|
|
else:
|
|
locator_uuid_map[appointment.locator] = [uuid]
|
|
|
|
return appointments, locator_uuid_map
|
|
|
|
@staticmethod
|
|
def build_jobs(jobs_data):
|
|
jobs = {}
|
|
tx_job_map = {}
|
|
|
|
for uuid, data in jobs_data.items():
|
|
job = Job.from_dict(data)
|
|
jobs[uuid] = job
|
|
|
|
if job.justice_txid in tx_job_map:
|
|
tx_job_map[job.justice_txid].append(uuid)
|
|
|
|
else:
|
|
tx_job_map[job.justice_txid] = [uuid]
|
|
|
|
return jobs, tx_job_map
|
|
|
|
@staticmethod
|
|
def build_block_queue(missed_blocks):
|
|
block_queue = Queue()
|
|
|
|
for block in missed_blocks:
|
|
block_queue.put(block)
|
|
|
|
return block_queue
|