@@ -109,6 +109,9 @@ async def start(self):
109109 axons
110110 )
111111
112+ # Get the last udpate
113+ last_update = await self .database .get_neuron_last_updated ()
114+
112115 # Determine whether a resync is needed
113116 time_to_resync = block - last_synced_block >= sync_interval
114117 must_resync = (
@@ -117,15 +120,20 @@ async def start(self):
117120 or has_axons_changed
118121 or has_missing_country
119122 or time_to_resync
123+ or last_update is None
120124 )
121125
122126 if not must_resync :
123127 btul .logging .debug (
124128 "No changes detected; skipping sync." ,
125129 prefix = self .settings .logging_name ,
126130 )
127- continue
131+
132+ # Notify listener the metagraph is ready
133+ ready = await self ._notify_if_needed (ready )
128134
135+ continue
136+
129137 if has_axons_changed :
130138 reason = "hotkey/IP changes detected"
131139 elif has_missing_country :
@@ -143,7 +151,9 @@ async def start(self):
143151 )
144152
145153 # Sync from chain and update Redis
146- axons , has_missing_country = await self ._resync ()
154+ axons , has_missing_country = await self ._resync (
155+ last_update = last_update
156+ )
147157
148158 # Store the sync block
149159 last_synced_block = block
@@ -202,7 +212,7 @@ async def stop(self):
202212 f"✅ MetagraphObserver service stopped" , prefix = self .settings .logging_name
203213 )
204214
205- async def _resync (self ) -> dict [str , str ]:
215+ async def _resync (self , last_update : bool ) -> dict [str , str ]:
206216 await self .metagraph .sync (subtensor = self .subtensor , lite = False )
207217 btul .logging .debug (
208218 "📡 Full metagraph sync complete" , prefix = self .settings .logging_name
@@ -247,7 +257,7 @@ async def _resync(self) -> dict[str, str]:
247257 else None
248258 )
249259 )
250-
260+
251261 except sccc .CountryApiException as e :
252262 btul .logging .error (f"🚨 Country API failure: { e } " )
253263 btul .logging .warning (
@@ -257,7 +267,9 @@ async def _resync(self) -> dict[str, str]:
257267 # Wait for the longest rate limit to expire (ensures all APIs are available)
258268 if e .rate_limited :
259269 max_wait = max (e .rate_limited .values ())
260- btul .logging .info (f"⏰ Waiting { max_wait :.0f} s for all APIs to recover..." )
270+ btul .logging .info (
271+ f"⏰ Waiting { max_wait :.0f} s for all APIs to recover..."
272+ )
261273 await asyncio .sleep (max_wait )
262274 else :
263275 await asyncio .sleep (60 ) # Default wait if no rate limit info
@@ -399,7 +411,7 @@ async def _resync(self) -> dict[str, str]:
399411 updated_neurons
400412 )
401413
402- if updated_neurons or neurons_to_delete :
414+ if last_update is None or updated_neurons or neurons_to_delete :
403415 block = await self .subtensor .get_current_block ()
404416 not self .settings .dry_run and await self .database .set_last_updated (block )
405417 btul .logging .debug (
0 commit comments