Add chunking to the websocket topics management
This commit is contained in:
1 parent
5f54c26f4a
commit
5d7a697c2b
1 file changed
+5
-2
+5
-2
@@ -14,6 +14,7 @@ from exceptions import MinerException, WebsocketClosed
|
|||||||
from constants import PING_INTERVAL, PING_TIMEOUT, MAX_WEBSOCKETS, WS_TOPICS_LIMIT
|
from constants import PING_INTERVAL, PING_TIMEOUT, MAX_WEBSOCKETS, WS_TOPICS_LIMIT
|
||||||
from utils import (
|
from utils import (
|
||||||
CHARS_ASCII,
|
CHARS_ASCII,
|
||||||
|
chunk,
|
||||||
task_wrapper,
|
task_wrapper,
|
||||||
create_nonce,
|
create_nonce,
|
||||||
json_minify,
|
json_minify,
|
||||||
@@ -210,11 +211,12 @@ class Websocket:
|
|||||||
if removed:
|
if removed:
|
||||||
topics_list = list(map(str, removed))
|
topics_list = list(map(str, removed))
|
||||||
ws_logger.debug(f"Websocket[{self._idx}]: Removing topics: {', '.join(topics_list)}")
|
ws_logger.debug(f"Websocket[{self._idx}]: Removing topics: {', '.join(topics_list)}")
|
||||||
|
for topics in chunk(topics_list, 20):
|
||||||
await self.send(
|
await self.send(
|
||||||
{
|
{
|
||||||
"type": "UNLISTEN",
|
"type": "UNLISTEN",
|
||||||
"data": {
|
"data": {
|
||||||
"topics": topics_list,
|
"topics": topics,
|
||||||
"auth_token": auth_state.access_token,
|
"auth_token": auth_state.access_token,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,11 +227,12 @@ class Websocket:
|
|||||||
if added:
|
if added:
|
||||||
topics_list = list(map(str, added))
|
topics_list = list(map(str, added))
|
||||||
ws_logger.debug(f"Websocket[{self._idx}]: Adding topics: {', '.join(topics_list)}")
|
ws_logger.debug(f"Websocket[{self._idx}]: Adding topics: {', '.join(topics_list)}")
|
||||||
|
for topics in chunk(topics_list, 20):
|
||||||
await self.send(
|
await self.send(
|
||||||
{
|
{
|
||||||
"type": "LISTEN",
|
"type": "LISTEN",
|
||||||
"data": {
|
"data": {
|
||||||
"topics": topics_list,
|
"topics": topics,
|
||||||
"auth_token": auth_state.access_token,
|
"auth_token": auth_state.access_token,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user