mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-18 14:44:21 +01:00
Adds Builder docstrings
This commit is contained in:
@@ -5,8 +5,29 @@ from pisa.appointment import Appointment
|
|||||||
|
|
||||||
|
|
||||||
class Builder:
|
class Builder:
|
||||||
|
"""
|
||||||
|
The ``Builder`` class is in charge or reconstructing data loaded from the database and build the data structures
|
||||||
|
of the :mod:`Watcher <pisa.watcher>` and the :mod:`Responder <pisa.responder>`.
|
||||||
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def build_appointments(appointments_data):
|
def build_appointments(appointments_data):
|
||||||
|
"""
|
||||||
|
Builds an appointments dictionary (``uuid: Appointment``) and a locator_uuid_map (``locator: uuid``) given a
|
||||||
|
dictionary of appointments from the database.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
appointments_data (dict): a dictionary of dictionaries representing all the :mod:`Watcher <pisa.watcher>`
|
||||||
|
appointments stored in the database. The structure is as follows:
|
||||||
|
|
||||||
|
``{uuid: {locator: str, start_time: int, ...}, uuid: {locator:...}}``
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
appointments, locator_uuid_map (tuple): A tuple with two dictionaries. ``appointments`` containing the
|
||||||
|
appointment information in :mod:`Appointment <pisa.appointment>` objects and ``locator_uuid_map``
|
||||||
|
containing a map of appointment (``uuid:locator``).
|
||||||
|
"""
|
||||||
|
|
||||||
appointments = {}
|
appointments = {}
|
||||||
locator_uuid_map = {}
|
locator_uuid_map = {}
|
||||||
|
|
||||||
@@ -24,6 +45,23 @@ class Builder:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def build_jobs(jobs_data):
|
def build_jobs(jobs_data):
|
||||||
|
"""
|
||||||
|
Builds a jobs dictionary (``uuid: Jobs``) and a tx_job_map (``penalty_txid: uuid``) given a dictionary of jobs
|
||||||
|
from the database.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
jobs_data (dict): a dictionary of dictionaries representing all the :mod:`Responder <pisa.responder>` jobs
|
||||||
|
stored in the database. The structure is as follows:
|
||||||
|
|
||||||
|
``{uuid: {locator: str, dispute_txid: str, ...}, uuid: {locator:...}}``
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
jobs, tx_job_map (tuple): A tuple with two dictionaries. ``jobs`` containing the jobs information in
|
||||||
|
:class:`Job <pisa.responder>` objects and a ``tx_job_map`` containing the map of jobs
|
||||||
|
(``penalty_txid: uuid``).
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
jobs = {}
|
jobs = {}
|
||||||
tx_job_map = {}
|
tx_job_map = {}
|
||||||
|
|
||||||
@@ -41,6 +79,17 @@ class Builder:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def build_block_queue(missed_blocks):
|
def build_block_queue(missed_blocks):
|
||||||
|
"""
|
||||||
|
Builds a ``Queue`` of block hashes to initialize the :mod:`Watcher <pisa.watcher>` or the
|
||||||
|
:mod:`Responder <pisa.responder>` using backed up data.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
missed_blocks (list): list of block hashes missed by the Watchtower (do to a crash or shutdown).
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
block_queue (Queue): A `Queue` containing all the missed blocks hashes.
|
||||||
|
"""
|
||||||
|
|
||||||
block_queue = Queue()
|
block_queue = Queue()
|
||||||
|
|
||||||
for block in missed_blocks:
|
for block in missed_blocks:
|
||||||
|
|||||||
Reference in New Issue
Block a user