From bc420da0e2ec34506263d0a8abef7019e1770194 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 15 Dec 2021 15:04:44 +0100 Subject: [PATCH] Maintain a sorted list of stored_msg_ids --- pyrogram/crypto/mtproto.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyrogram/crypto/mtproto.py b/pyrogram/crypto/mtproto.py index 1eec7b7a..81cf56f4 100644 --- a/pyrogram/crypto/mtproto.py +++ b/pyrogram/crypto/mtproto.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +import bisect from hashlib import sha256 from io import BytesIO from os import urandom @@ -118,6 +119,6 @@ def unpack( if time_diff < -300: return None - stored_msg_ids.append(message.msg_id) + bisect.insort(stored_msg_ids, message.msg_id) return message