File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,7 @@ async def _update_filter(self):
205205 @asynccontextmanager
206206 async def _filter (self , topics : list [str ]):
207207 for topic in topics :
208+ protocol .ADD_KNOWN_TOPIC (topic )
208209 self ._filters [topic ] = self ._filters .get (topic , 0 ) + 1
209210 await self ._update_filter ()
210211 yield
@@ -215,6 +216,7 @@ async def _filter(self, topics: list[str]):
215216 await self ._update_filter ()
216217
217218 async def mint_scoped_token (self , topic : str ) -> bytes :
219+ protocol .ADD_KNOWN_TOPIC (topic )
218220 topic_hash = sha1 (topic .encode ()).digest ()
219221 await self ._send (
220222 protocol .ScopedTokenCommand (token = await self .base_token , topic = topic_hash )
Original file line number Diff line number Diff line change 1212KNOWN_TOPICS_LOOKUP = {sha1 (topic .encode ()).digest ():topic for topic in KNOWN_TOPICS }
1313# fmt: on
1414
15+ def ADD_KNOWN_TOPIC (topic : str ):
16+ # Add a topic and hash to the known topics and lookup
17+ if topic not in KNOWN_TOPICS :
18+ KNOWN_TOPICS .add (topic )
19+ topic_hash = sha1 (topic .encode ()).digest ()
20+ KNOWN_TOPICS_LOOKUP [topic_hash ] = topic
1521
1622@dataclass
1723class Command :
@@ -177,6 +183,9 @@ def __post_init__(self):
177183 and self .outgoing is not None
178184 ) and not (self ._token_topic_1 is not None and self ._token_topic_2 is not None ):
179185 raise ValueError ("topic, token, and outgoing must be set." )
186+
187+ if self .topic is not None and isinstance (self .topic , str ):
188+ ADD_KNOWN_TOPIC (self .topic )
180189
181190 if self .outgoing is True :
182191 assert self .topic and self .token
You can’t perform that action at this time.
0 commit comments