mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 22:24:23 +01:00
Merge branch 'testing' into 13-appointment-signature
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import json
|
import json
|
||||||
from flask import Flask, request, Response, abort, jsonify
|
from flask import Flask, request, Response, abort, jsonify
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
@@ -12,6 +13,7 @@ from pisa.block_processor import BlockProcessor
|
|||||||
|
|
||||||
# ToDo: #5-add-async-to-api
|
# ToDo: #5-add-async-to-api
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
HTTP_OK = 200
|
HTTP_OK = 200
|
||||||
HTTP_BAD_REQUEST = 400
|
HTTP_BAD_REQUEST = 400
|
||||||
HTTP_SERVICE_UNAVAILABLE = 503
|
HTTP_SERVICE_UNAVAILABLE = 503
|
||||||
@@ -135,7 +137,8 @@ def start_api():
|
|||||||
watcher = Watcher()
|
watcher = Watcher()
|
||||||
inspector = Inspector()
|
inspector = Inspector()
|
||||||
|
|
||||||
# Setting Flask log t ERROR only so it does not mess with out logging
|
# Setting Flask log to ERROR only so it does not mess with out logging. Also disabling flask initial messages
|
||||||
logging.getLogger('werkzeug').setLevel(logging.ERROR)
|
logging.getLogger('werkzeug').setLevel(logging.ERROR)
|
||||||
|
os.environ['WERKZEUG_RUN_MAIN'] = 'true'
|
||||||
|
|
||||||
app.run(host=HOST, port=PORT)
|
app.run(host=HOST, port=PORT)
|
||||||
|
|||||||
@@ -88,20 +88,20 @@ class Responder:
|
|||||||
if confirmations == 0:
|
if confirmations == 0:
|
||||||
self.unconfirmed_txs.append(justice_txid)
|
self.unconfirmed_txs.append(justice_txid)
|
||||||
|
|
||||||
logger.info("New job added.",
|
logger.info("New job added.", dispute_txid=dispute_txid, justice_txid=justice_txid,
|
||||||
dispute_txid=dispute_txid, justice_txid=justice_txid, appointment_end=appointment_end)
|
appointment_end=appointment_end)
|
||||||
|
|
||||||
if self.asleep:
|
if self.asleep:
|
||||||
self.asleep = False
|
self.asleep = False
|
||||||
self.block_queue = Queue()
|
self.block_queue = Queue()
|
||||||
zmq_thread = Thread(target=self.do_subscribe, args=[self.block_queue])
|
zmq_thread = Thread(target=self.do_subscribe)
|
||||||
responder = Thread(target=self.do_watch)
|
responder = Thread(target=self.do_watch)
|
||||||
zmq_thread.start()
|
zmq_thread.start()
|
||||||
responder.start()
|
responder.start()
|
||||||
|
|
||||||
def do_subscribe(self, block_queue):
|
def do_subscribe(self):
|
||||||
self.zmq_subscriber = ZMQHandler(parent='Responder')
|
self.zmq_subscriber = ZMQHandler(parent='Responder')
|
||||||
self.zmq_subscriber.handle(block_queue)
|
self.zmq_subscriber.handle(self.block_queue)
|
||||||
|
|
||||||
def do_watch(self):
|
def do_watch(self):
|
||||||
# ToDo: #9-add-data-persistence
|
# ToDo: #9-add-data-persistence
|
||||||
|
|||||||
Reference in New Issue
Block a user