Make MtProtoSender._need_confirmation a set

This will avoid adding duplicated items to it
This commit is contained in:
Lonami Exo 2017-10-20 22:07:45 +02:00
parent 83595a0e2d
commit 033119e9b8

View File

@ -39,7 +39,7 @@ class MtProtoSender:
self._logger = logging.getLogger(__name__) self._logger = logging.getLogger(__name__)
# Message IDs that need confirmation # Message IDs that need confirmation
self._need_confirmation = [] self._need_confirmation = set()
# Requests (as msg_id: Message) sent waiting to be received # Requests (as msg_id: Message) sent waiting to be received
self._pending_receive = {} self._pending_receive = {}
@ -74,7 +74,7 @@ class MtProtoSender:
# Pack everything in the same container if we need to send AckRequests # Pack everything in the same container if we need to send AckRequests
if self._need_confirmation: if self._need_confirmation:
messages.append( messages.append(
TLMessage(self.session, MsgsAck(self._need_confirmation)) TLMessage(self.session, MsgsAck(list(self._need_confirmation)))
) )
self._need_confirmation.clear() self._need_confirmation.clear()
@ -183,7 +183,7 @@ class MtProtoSender:
) )
return False return False
self._need_confirmation.append(msg_id) self._need_confirmation.add(msg_id)
code = reader.read_int(signed=False) code = reader.read_int(signed=False)
reader.seek(-4) reader.seek(-4)