Add chunking to the websocket topics management

This commit is contained in:
DevilXD committed 2025-11-19 21:24:08 +01:00
1 parent 5f54c26f4a
commit 5d7a697c2b
1 file changed
+5 -2
+5 -2
View File
@@ -14,6 +14,7 @@ from exceptions import MinerException, WebsocketClosed
from constants import PING_INTERVAL, PING_TIMEOUT, MAX_WEBSOCKETS, WS_TOPICS_LIMIT
from utils import (
CHARS_ASCII,
chunk,
task_wrapper,
create_nonce,
json_minify,
@@ -210,11 +211,12 @@ class Websocket:
if removed:
topics_list = list(map(str, removed))
ws_logger.debug(f"Websocket[{self._idx}]: Removing topics: {', '.join(topics_list)}")
for topics in chunk(topics_list, 20):
await self.send(
{
"type": "UNLISTEN",
"data": {
"topics": topics_list,
"topics": topics,
"auth_token": auth_state.access_token,
}
}
@@ -225,11 +227,12 @@ class Websocket:
if added:
topics_list = list(map(str, added))
ws_logger.debug(f"Websocket[{self._idx}]: Adding topics: {', '.join(topics_list)}")
for topics in chunk(topics_list, 20):
await self.send(
{
"type": "LISTEN",
"data": {
"topics": topics_list,
"topics": topics,
"auth_token": auth_state.access_token,
}
}