@@ -181,7 +181,10 @@ impl<T: Config> Pallet<T> {
181181 /// Loads all records from ChildKeys and ParentKeys where (hotkey, netuid) is the key.
182182 /// Produces a parent->(child->prop) adjacency map that **cannot violate**
183183 /// the required consistency because all inserts go through `link`.
184- fn load_child_parent_relations ( hotkey : & T :: AccountId , netuid : NetUid ) -> PCRelations < T > {
184+ fn load_child_parent_relations (
185+ hotkey : & T :: AccountId ,
186+ netuid : NetUid ,
187+ ) -> Result < PCRelations < T > , DispatchError > {
185188 let mut rel = PCRelations :: < T > :: new ( hotkey. clone ( ) ) ;
186189
187190 // Load children: (prop, child) from ChildKeys(hotkey, netuid)
@@ -194,7 +197,7 @@ impl<T: Config> Pallet<T> {
194197 }
195198 }
196199 // Validate & set (enforce no self-loop and sum limit)
197- let _ = rel. link_children ( children) ;
200+ rel. link_children ( children) ? ;
198201
199202 // Load parents: (prop, parent) from ParentKeys(hotkey, netuid)
200203 let parent_links = ParentKeys :: < T > :: get ( hotkey, netuid) ;
@@ -205,9 +208,9 @@ impl<T: Config> Pallet<T> {
205208 }
206209 }
207210 // Keep the same validation rules for parents (no self-loop, bounded sum).
208- let _ = rel. link_parents ( parents) ;
211+ rel. link_parents ( parents) ? ;
209212
210- rel
213+ Ok ( rel)
211214 }
212215
213216 /// Build a `PCRelations` for `pivot` (parent) from the `PendingChildKeys` queue,
@@ -383,7 +386,7 @@ impl<T: Config> Pallet<T> {
383386 weight : & mut Weight ,
384387 ) -> DispatchResult {
385388 // 1) Load the current relations around old_hotkey
386- let mut relations = Self :: load_child_parent_relations ( old_hotkey, netuid) ;
389+ let mut relations = Self :: load_child_parent_relations ( old_hotkey, netuid) ? ;
387390 weight. saturating_accrue ( T :: DbWeight :: get ( ) . reads_writes ( 2 , 0 ) ) ;
388391
389392 // 2) Clean up all storage entries that reference old_hotkey
@@ -514,7 +517,7 @@ impl<T: Config> Pallet<T> {
514517 // - Each child is not the hotkey.
515518 // - The sum of the proportions does not exceed u64::MAX.
516519 // - Bipartite separation (no A <-> B relations)
517- let relations = Self :: load_child_parent_relations ( & hotkey, netuid) ;
520+ let relations = Self :: load_child_parent_relations ( & hotkey, netuid) ? ;
518521 relations. ensure_pending_consistency ( & children) ?;
519522
520523 // Check that the parent key has at least the minimum own stake
0 commit comments