mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 14:14:22 +01:00
Refactor add_appointment cli code
This commit is contained in:
@@ -3,7 +3,7 @@ from queue import Queue
|
||||
from threading import Thread
|
||||
|
||||
from common.cryptographer import Cryptographer
|
||||
from common.constants import LOCATOR_LEN_HEX
|
||||
from common.tools import compute_locator
|
||||
|
||||
from common.logger import Logger
|
||||
from pisa.cleaner import Cleaner
|
||||
@@ -71,20 +71,6 @@ class Watcher:
|
||||
if not isinstance(responder, Responder):
|
||||
self.responder = Responder(db_manager)
|
||||
|
||||
@staticmethod
|
||||
def compute_locator(tx_id):
|
||||
"""
|
||||
Computes an appointment locator given a transaction id.
|
||||
|
||||
Args:
|
||||
tx_id (:obj:`str`): the transaction id used to compute the locator.
|
||||
|
||||
Returns:
|
||||
(:obj:`str`): The computed locator.
|
||||
"""
|
||||
|
||||
return tx_id[:LOCATOR_LEN_HEX]
|
||||
|
||||
def add_appointment(self, appointment):
|
||||
"""
|
||||
Adds a new appointment to the ``appointments`` dictionary if ``max_appointments`` has not been reached.
|
||||
@@ -238,7 +224,7 @@ class Watcher:
|
||||
found.
|
||||
"""
|
||||
|
||||
potential_locators = {Watcher.compute_locator(txid): txid for txid in txids}
|
||||
potential_locators = {compute_locator(txid): txid for txid in txids}
|
||||
|
||||
# Check is any of the tx_ids in the received block is an actual match
|
||||
intersection = set(self.locator_uuid_map.keys()).intersection(potential_locators.keys())
|
||||
|
||||
Reference in New Issue
Block a user