updated : seen message map type to bool from int

This commit is contained in:
Mystical
2025-02-25 01:07:04 +05:30
committed by Paul Robinson
parent f392f47822
commit 0fa8711ca7
2 changed files with 3 additions and 4 deletions

View File

@ -53,6 +53,7 @@ from .pubsub import (
)
PROTOCOL_ID = TProtocol("/meshsub/1.0.0")
PROTOCOL_ID_V11 = TProtocol("/meshsub/1.1.0")
logger = logging.getLogger("libp2p.pubsub.gossipsub")

View File

@ -112,7 +112,7 @@ class Pubsub(Service, IPubsub):
peer_receive_channel: trio.MemoryReceiveChannel[ID]
dead_peer_receive_channel: trio.MemoryReceiveChannel[ID]
seen_messages: LRU[bytes, int]
seen_messages: LRU[bytes, bool]
subscribed_topics_send: dict[str, trio.MemorySendChannel[rpc_pb2.Message]]
subscribed_topics_receive: dict[str, TrioSubscriptionAPI]
@ -666,9 +666,7 @@ class Pubsub(Service, IPubsub):
def _mark_msg_seen(self, msg: rpc_pb2.Message) -> None:
msg_id = self._msg_id_constructor(msg)
# FIXME: Mapping `msg_id` to `1` is quite awkward. Should investigate if there
# is a more appropriate way.
self.seen_messages[msg_id] = 1
self.seen_messages[msg_id] = True
def _is_subscribed_to_msg(self, msg: rpc_pb2.Message) -> bool:
return any(topic in self.topic_ids for topic in msg.topicIDs)