From 8aba0f7dafa6b56741d8f74e03454e17d9ba2300 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Date: Fri, 5 Apr 2019 18:35:05 +0100 Subject: [PATCH] Comments and sleep -> asleep --- pisa-btc/pisa/watcher.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pisa-btc/pisa/watcher.py b/pisa-btc/pisa/watcher.py index f357921..9381477 100644 --- a/pisa-btc/pisa/watcher.py +++ b/pisa-btc/pisa/watcher.py @@ -34,12 +34,21 @@ class Watcher: def __init__(self, max_appointments=MAX_APPOINTMENTS): self.appointments = dict() self.block_queue = Queue() - self.sleep = True + self.asleep = True self.max_appointments = max_appointments def add_appointment(self, appointment, debug): # ToDo: Discuss about validation of input data + # Rationale: + # The Watcher will analyze every received block looking for appointment matches. If there is no work + # to do the watcher can sleep (appointments = {} and sleep = True) otherwise for every received block + # the watcher will get the list of transactions and compare it with the list of appointments. + # If the watcher is awake, every new appointment will just be added to the appointment list until + # max_appointments is reached. + + # ToDo: Check how to handle appointment completion + if len(self.appointments) < self.max_appointments: # Appointments are identified by the locator: the most significant 16 bytes of the commitment txid. # While 16-byte hash collisions are not likely, they are possible, so we will store appointments in lists @@ -52,8 +61,8 @@ class Watcher: appointment.id = len(self.appointments[appointment.locator]) self.appointments[appointment.locator].append(appointment) - if self.sleep: - self.sleep = False + if self.asleep: + self.asleep = False zmq_subscriber = Thread(target=self.do_subscribe, args=[self.block_queue, debug]) watcher = Thread(target=self.do_watch, args=[debug]) zmq_subscriber.start() @@ -61,10 +70,6 @@ class Watcher: appointment_added = True - # Rationale: - # The Watcher will analyze every received block looking for appointment matches. If there is no work - # to do the watcher can sleep (appointments = [] and sleep = True) otherwise for every received block - # the watcher will get the list of transactions and compare it with the list of appointments else: appointment_added = False