We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2a1af2b commit c2a29c8Copy full SHA for c2a29c8
1 file changed
pyrogram/crypto/mtproto.py
@@ -26,6 +26,8 @@
26
from . import aes
27
from ..session.internals import MsgId
28
29
+STORED_MSG_IDS_MAX_SIZE = 1000 * 2
30
+
31
32
def kdf(auth_key: bytes, msg_key: bytes, outgoing: bool) -> tuple:
33
# https://core.telegram.org/mtproto/description#defining-aes-key-and-initialization-vector
@@ -97,8 +99,8 @@ def unpack(
97
99
# https://core.telegram.org/mtproto/security_guidelines#checking-msg-id
98
100
assert message.msg_id % 2 != 0
101
- if len(stored_msg_ids) > 200:
- stored_msg_ids = stored_msg_ids[50:]
102
+ if len(stored_msg_ids) > STORED_MSG_IDS_MAX_SIZE:
103
+ del stored_msg_ids[:STORED_MSG_IDS_MAX_SIZE // 2]
104
105
if stored_msg_ids:
106
# Ignored message: msg_id is lower than all of the stored values
0 commit comments