mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 22:24:23 +01:00
Minor refactor
Runs chain_monitor as daemon so it terminates along with the main thread. Reorders attack_responder so it is in the same stanza as attack_watcher
This commit is contained in:
@@ -53,11 +53,11 @@ class ChainMonitor:
|
||||
|
||||
def monitor_chain(self):
|
||||
self.best_tip = BlockProcessor.get_best_block_hash()
|
||||
Thread(target=self.monitor_chain_polling).start()
|
||||
Thread(target=self.monitor_chain_zmq).start()
|
||||
Thread(target=self.monitor_chain_polling, daemon=True).start()
|
||||
Thread(target=self.monitor_chain_zmq, daemon=True).start()
|
||||
|
||||
def monitor_chain_polling(self):
|
||||
while self.terminate:
|
||||
while not self.terminate:
|
||||
self.check_tip.wait(timeout=60)
|
||||
|
||||
# Terminate could have been set wile the thread was blocked in wait
|
||||
|
||||
@@ -59,6 +59,7 @@ if __name__ == "__main__":
|
||||
|
||||
watcher = Watcher(db_manager, chain_monitor, secret_key_der)
|
||||
chain_monitor.attach_watcher(watcher.block_queue, watcher.asleep)
|
||||
chain_monitor.attach_responder(watcher.responder.block_queue, watcher.responder.asleep)
|
||||
|
||||
if len(watcher_appointments_data) == 0 and len(responder_trackers_data) == 0:
|
||||
logger.info("Fresh bootstrap")
|
||||
@@ -87,8 +88,6 @@ if __name__ == "__main__":
|
||||
watcher.responder.block_queue = Builder.build_block_queue(missed_blocks_responder)
|
||||
|
||||
# Build Watcher. If the blocks of both match we don't perform the search twice.
|
||||
chain_monitor.attach_responder(watcher.responder.block_queue, watcher.responder.asleep)
|
||||
|
||||
if last_block_watcher is not None:
|
||||
if last_block_watcher == last_block_responder:
|
||||
missed_blocks_watcher = missed_blocks_responder
|
||||
|
||||
Reference in New Issue
Block a user