teos.builder¶
-
class
Builder[source]¶ Bases:
objectThe
Builderclass is in charge of reconstructing data loaded from the appointments database and build the data structures of theWatcherand theResponder.-
static
build_appointments(appointments_data)[source]¶ Builds an appointments dictionary (
uuid:extended_appointment) and a locator_uuid_map (locator:uuid) given a dictionary of appointments from the database.- Parameters
appointments_data (
dict) –a dictionary of dictionaries representing all the
Watcherappointments stored in the database. The structure is as follows:{uuid: {locator: str, ...}, uuid: {locator:...}}- Returns
A tuple with two dictionaries.
appointmentscontaining the appointment information inExtendedAppointmentobjects andlocator_uuid_mapcontaining a map of appointment (uuid:locator).- Return type
tuple
-
static
build_trackers(tracker_data)[source]¶ Builds a tracker dictionary (
uuid:TransactionTracker) and a tx_tracker_map (penalty_txid:uuid) given a dictionary of trackers from the database.- Parameters
tracker_data (
dict) –a dictionary of dictionaries representing all the
Respondertrackers stored in the database. The structure is as follows:{uuid: {locator: str, dispute_txid: str, ...}, uuid: {locator:...}}- Returns
A tuple with two dictionaries.
trackerscontaining the trackers’ information inTransactionTrackerobjects and atx_tracker_mapcontaining the map of trackers (penalty_txid: uuid).- Return type
tuple
-
static
populate_block_queue(block_queue, missed_blocks)[source]¶ Populates a
Queueof block hashes to initialize theWatcheror theResponderusing backed up data.- Parameters
block_queue (
Queue) – a queue.missed_blocks (
list) – list of block hashes missed by the Watchtower (due to a crash or shutdown).
- Returns
A queue containing all the missed blocks hashes.
- Return type
Queue
-
static
update_states(watcher, missed_blocks_watcher, missed_blocks_responder)[source]¶ Updates the states of both the
Watcherand theResponder. If both have pending blocks to process they need to be updated at the same time, block by block.If only one instance has to be updated,
populate_block_queueshould be used.- Parameters
watcher (
Watcher) – aWatcherinstance (including aResponder).missed_blocks_watcher (
list) – the list of block missed by theWatcher.missed_blocks_responder (
list) – the list of block missed by theResponder.
- Raises
ValueError – if one of the provided list is empty.
-
static