Several fixes and improvements

This commit is contained in:
Salvatore Ingala
2019-10-09 09:30:32 +07:00
parent a53e7a82e3
commit c524319027
7 changed files with 52 additions and 20 deletions

View File

@@ -3,8 +3,6 @@ import binascii
from pisa import Logger
from pisa.conf import FEED_PROTOCOL, FEED_ADDR, FEED_PORT
logger = Logger("ZMQHandler")
# ToDo: #7-add-async-back-to-zmq
class ZMQHandler:
@@ -15,7 +13,8 @@ class ZMQHandler:
self.zmqSubSocket.setsockopt(zmq.RCVHWM, 0)
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "hashblock")
self.zmqSubSocket.connect("%s://%s:%s" % (FEED_PROTOCOL, FEED_ADDR, FEED_PORT))
self.parent = parent
self.logger = Logger("ZMQHandler-{}".format(parent))
self.terminate = False
def handle(self, block_queue):
@@ -31,6 +30,4 @@ class ZMQHandler:
block_hash = binascii.hexlify(body).decode('UTF-8')
block_queue.put(block_hash)
logger.info("new block received via ZMQ",
parent=self.parent,
block_hash=block_hash)
self.logger.info("new block received via ZMQ", block_hash=block_hash)