mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-27 16:45:19 +00:00
Tune stored_msg_ids max size
This commit is contained in:
parent
2a1af2b8e9
commit
c2a29c8c30
@ -26,6 +26,8 @@ from pyrogram.raw.core import Message, Long
|
|||||||
from . import aes
|
from . import aes
|
||||||
from ..session.internals import MsgId
|
from ..session.internals import MsgId
|
||||||
|
|
||||||
|
STORED_MSG_IDS_MAX_SIZE = 1000 * 2
|
||||||
|
|
||||||
|
|
||||||
def kdf(auth_key: bytes, msg_key: bytes, outgoing: bool) -> tuple:
|
def kdf(auth_key: bytes, msg_key: bytes, outgoing: bool) -> tuple:
|
||||||
# https://core.telegram.org/mtproto/description#defining-aes-key-and-initialization-vector
|
# https://core.telegram.org/mtproto/description#defining-aes-key-and-initialization-vector
|
||||||
@ -97,8 +99,8 @@ def unpack(
|
|||||||
# https://core.telegram.org/mtproto/security_guidelines#checking-msg-id
|
# https://core.telegram.org/mtproto/security_guidelines#checking-msg-id
|
||||||
assert message.msg_id % 2 != 0
|
assert message.msg_id % 2 != 0
|
||||||
|
|
||||||
if len(stored_msg_ids) > 200:
|
if len(stored_msg_ids) > STORED_MSG_IDS_MAX_SIZE:
|
||||||
stored_msg_ids = stored_msg_ids[50:]
|
del stored_msg_ids[:STORED_MSG_IDS_MAX_SIZE // 2]
|
||||||
|
|
||||||
if stored_msg_ids:
|
if stored_msg_ids:
|
||||||
# Ignored message: msg_id is lower than all of the stored values
|
# Ignored message: msg_id is lower than all of the stored values
|
||||||
|
Loading…
Reference in New Issue
Block a user