@@ -47,11 +47,13 @@ async def get_selected_miners(self, ss58_address: str):
4747 """
4848 Return selected uids for a hotkey using versioned selection models.
4949 """
50+ # Ensure Redis connection is established before any operation.
5051 await self .ensure_connection ()
5152
52- # Get a client
53+ # Get a connected Redis client, configured with the correct DB index and prefix.
5354 client = await self .get_client ()
5455
56+ # Get currently active versions of the "selection" schema to use during read.
5557 _ , active = await self ._get_migration_status ("selection" )
5658
5759 for version in reversed (active ): # Prefer latest version
@@ -79,11 +81,13 @@ async def set_selection_miners(self, ss58_address: str, uids: list[int]):
7981 """
8082 Store selected miner UIDs in all active selection model versions.
8183 """
84+ # Ensure Redis connection is established before any operation.
8285 await self .ensure_connection ()
8386
84- # Get a client
87+ # Get a connected Redis client, configured with the correct DB index and prefix.
8588 client = await self .get_client ()
8689
90+ # Get currently active versions of the "selection" schema to use during read.
8791 _ , active = await self ._get_migration_status ("selection" )
8892
8993 for version in active :
@@ -106,12 +110,13 @@ async def set_selection_miners(self, ss58_address: str, uids: list[int]):
106110 return None
107111
108112 async def get_miner (self , hotkey : str ) -> Miner :
109- # Ensure the connection is up and running
113+ # Ensure Redis connection is established before any operation.
110114 await self .ensure_connection ()
111115
112- # Get a client
116+ # Get a connected Redis client, configured with the correct DB index and prefix.
113117 client = await self .get_client ()
114118
119+ # Get currently active versions of the "miner" schema to use during read.
115120 _ , active = await self ._get_migration_status ("miner" )
116121
117122 for version in reversed (active ):
@@ -136,12 +141,13 @@ async def get_miner(self, hotkey: str) -> Miner:
136141 return None
137142
138143 async def get_miners (self ) -> dict [str , Miner ]:
139- # Ensure the connection is up and running
144+ # Ensure Redis connection is established before any operation.
140145 await self .ensure_connection ()
141146
142- # Get a client
147+ # Get a connected Redis client, configured with the correct DB index and prefix.
143148 client = await self .get_client ()
144149
150+ # Get currently active versions of the "miner" schema to use during read.
145151 _ , active = await self ._get_migration_status ("miner" )
146152
147153 for version in reversed (active ):
@@ -169,11 +175,13 @@ async def add_miner(self, miner: Miner):
169175 """
170176 Add a new miner record to all active versions of the miner schema.
171177 """
178+ # Ensure Redis connection is established before any operation.
172179 await self .ensure_connection ()
173180
174- # Get a client
181+ # Get a connected Redis client, configured with the correct DB index and prefix.
175182 client = await self .get_client ()
176183
184+ # Get currently active versions of the "miner" schema to use during read.
177185 _ , active = await self ._get_migration_status ("miner" )
178186
179187 for version in active :
@@ -200,11 +208,13 @@ async def update_miner(self, miner: Miner):
200208 """
201209 Update an existing miner record.
202210 """
211+ # Ensure Redis connection is established before any operation.
203212 await self .ensure_connection ()
204213
205- # Get a client
214+ # Get a connected Redis client, configured with the correct DB index and prefix.
206215 client = await self .get_client ()
207216
217+ # Get currently active versions of the "miner" schema to use during read.
208218 _ , active = await self ._get_migration_status ("miner" )
209219
210220 for version in reversed (active ):
@@ -231,11 +241,13 @@ async def update_miners(self, miners: List[Miner]):
231241 """
232242 Bulk update for a list of miners using active model versions.
233243 """
244+ # Ensure Redis connection is established before any operation.
234245 await self .ensure_connection ()
235246
236- # Get a client
247+ # Get a connected Redis client, configured with the correct DB index and prefix.
237248 client = await self .get_client ()
238249
250+ # Get currently active versions of the "miner" schema to use during read.
239251 _ , active = await self ._get_migration_status ("miner" )
240252
241253 for version in reversed (active ):
@@ -262,9 +274,10 @@ async def remove_miner(self, miner: Miner):
262274 """
263275 Remove a single miner entry from all available versions.
264276 """
277+ # Ensure Redis connection is established before any operation.
265278 await self .ensure_connection ()
266279
267- # Get a client
280+ # Get a connected Redis client, configured with the correct DB index and prefix.
268281 client = await self .get_client ()
269282
270283 for version , model in self .models ["miner" ].items ():
@@ -287,9 +300,10 @@ async def remove_miners(self, miners: List[Miner]):
287300 """
288301 Remove a single miner entry from all available versions.
289302 """
303+ # Ensure Redis connection is established before any operation.
290304 await self .ensure_connection ()
291305
292- # Get a client
306+ # Get a connected Redis client, configured with the correct DB index and prefix.
293307 client = await self .get_client ()
294308
295309 for version , model in self .models ["miner" ].items ():
0 commit comments