fix: add forgotten subscription message
This commit is contained in:
parent
571be9ed7b
commit
f13d581c66
@ -1 +1,4 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
WS_ADDR = "wss://ws.blockchain.info/coins"
|
WS_ADDR = "wss://ws.blockchain.info/coins"
|
||||||
|
SUB_MSG = json.dumps({"coin": "eth", "command": "subscribe", "entity": "confirmed_transaction"})
|
||||||
|
@ -4,18 +4,23 @@ import threading
|
|||||||
import logging
|
import logging
|
||||||
import websockets
|
import websockets
|
||||||
|
|
||||||
from const import WS_ADDR
|
from const import WS_ADDR, SUB_MSG
|
||||||
|
|
||||||
|
|
||||||
class WebSocketThread(threading.Thread):
|
class WebSocketThread(threading.Thread):
|
||||||
def __init__(self, q, shutdown_event):
|
def __init__(self, q, shutdown_event, sub_msg=SUB_MSG):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.q = q
|
self.q = q
|
||||||
self.shutdown_event = shutdown_event
|
self.shutdown_event = shutdown_event
|
||||||
|
self.sub_msg = sub_msg
|
||||||
self.tx_count = 0
|
self.tx_count = 0
|
||||||
|
|
||||||
async def connect(self):
|
async def connect(self):
|
||||||
async with websockets.connect(WS_ADDR) as ws:
|
async with websockets.connect(WS_ADDR) as ws:
|
||||||
|
logging.info("WebSocket connection established successfully")
|
||||||
|
await ws.send(self.sub_msg)
|
||||||
|
logging.info("Subscription message sent")
|
||||||
|
|
||||||
while not self.shutdown_event.is_set():
|
while not self.shutdown_event.is_set():
|
||||||
try:
|
try:
|
||||||
msg = await ws.recv()
|
msg = await ws.recv()
|
||||||
|
Loading…
Reference in New Issue
Block a user