@@ -156,6 +156,28 @@ impl<T: Config> PCRelations<T> {
156156}
157157
158158impl < T : Config > Pallet < T > {
159+ /// Set childkeys vector making sure there are no empty vectors in the state
160+ fn set_childkeys ( parent : T :: AccountId , netuid : NetUid , childkey_vec : Vec < ( u64 , T :: AccountId ) > ) {
161+ if childkey_vec. is_empty ( ) {
162+ ChildKeys :: < T > :: remove ( parent, netuid) ;
163+ } else {
164+ ChildKeys :: < T > :: insert ( parent, netuid, childkey_vec) ;
165+ }
166+ }
167+
168+ /// Set parentkeys vector making sure there are no empty vectors in the state
169+ fn set_parentkeys (
170+ child : T :: AccountId ,
171+ netuid : NetUid ,
172+ parentkey_vec : Vec < ( u64 , T :: AccountId ) > ,
173+ ) {
174+ if parentkey_vec. is_empty ( ) {
175+ ParentKeys :: < T > :: remove ( child, netuid) ;
176+ } else {
177+ ParentKeys :: < T > :: insert ( child, netuid, parentkey_vec) ;
178+ }
179+ }
180+
159181 /// Loads all records from ChildKeys and ParentKeys where (hotkey, netuid) is the key.
160182 /// Produces a parent->(child->prop) adjacency map that **cannot violate**
161183 /// the required consistency because all inserts go through `link`.
@@ -759,30 +781,6 @@ impl<T: Config> Pallet<T> {
759781 ) ;
760782 }
761783
762- pub fn set_childkeys (
763- parent : T :: AccountId ,
764- netuid : NetUid ,
765- childkey_vec : Vec < ( u64 , T :: AccountId ) > ,
766- ) {
767- if childkey_vec. is_empty ( ) {
768- ChildKeys :: < T > :: remove ( parent, netuid) ;
769- } else {
770- ChildKeys :: < T > :: insert ( parent, netuid, childkey_vec) ;
771- }
772- }
773-
774- pub fn set_parentkeys (
775- child : T :: AccountId ,
776- netuid : NetUid ,
777- parentkey_vec : Vec < ( u64 , T :: AccountId ) > ,
778- ) {
779- if parentkey_vec. is_empty ( ) {
780- ParentKeys :: < T > :: remove ( child, netuid) ;
781- } else {
782- ParentKeys :: < T > :: insert ( child, netuid, parentkey_vec) ;
783- }
784- }
785-
786784 /// Remove self-loops in `ChildKeys` and `ParentKeys`.
787785 /// If, after removal, a value-vector becomes empty, the storage key is removed.
788786 pub fn clean_self_loops ( weight : & mut Weight ) {
0 commit comments