@@ -70,8 +70,8 @@ impl<T: Config> Pallet<T> {
7070 // We check the callers (hotkey) signature.
7171 let hotkey_id = ensure_signed ( origin) ?;
7272
73- // Validate user input
74- Self :: validate_serve_axon (
73+ // Validate user input and build the axon struct.
74+ let mut prev_axon = Self :: validate_serve_axon (
7575 & hotkey_id,
7676 netuid,
7777 version,
@@ -90,17 +90,8 @@ impl<T: Config> Pallet<T> {
9090 NeuronCertificates :: < T > :: insert ( netuid, hotkey_id. clone ( ) , certificate)
9191 }
9292
93- // We insert the axon meta.
94- let mut prev_axon = Self :: get_axon_info ( netuid, & hotkey_id) ;
93+ // Record the block at insert time.
9594 prev_axon. block = Self :: get_current_block_as_u64 ( ) ;
96- prev_axon. version = version;
97- prev_axon. ip = ip;
98- prev_axon. port = port;
99- prev_axon. ip_type = ip_type;
100- prev_axon. protocol = protocol;
101- prev_axon. placeholder1 = placeholder1;
102- prev_axon. placeholder2 = placeholder2;
103-
10495 Axons :: < T > :: insert ( netuid, hotkey_id. clone ( ) , prev_axon) ;
10596
10697 // We deposit axon served event.
@@ -137,11 +128,8 @@ impl<T: Config> Pallet<T> {
137128 /// - On successfully serving the axon info.
138129 ///
139130 /// # Raises:
140- /// * 'MechanismDoesNotExist':
141- /// - Attempting to set weights on a non-existent network.
142- ///
143- /// * 'NotRegistered':
144- /// - Attempting to set weights from a non registered account.
131+ /// * 'HotKeyNotRegisteredInNetwork':
132+ /// - Attempting to serve prometheus from a hotkey not registered on the target network.
145133 ///
146134 /// * 'InvalidIpType':
147135 /// - The ip type is not 4 or 6.
@@ -321,7 +309,7 @@ impl<T: Config> Pallet<T> {
321309 protocol : u8 ,
322310 placeholder1 : u8 ,
323311 placeholder2 : u8 ,
324- ) -> Result < ( ) , Error < T > > {
312+ ) -> Result < AxonInfoOf , Error < T > > {
325313 // Ensure the hotkey is registered on this specific network.
326314 ensure ! (
327315 Self :: is_hotkey_registered_on_network( netuid, hotkey_id) ,
@@ -344,8 +332,8 @@ impl<T: Config> Pallet<T> {
344332 Error :: <T >:: ServingRateLimitExceeded
345333 ) ;
346334
347- // Validate axon data with delegate func
348- prev_axon. block = Self :: get_current_block_as_u64 ( ) ;
335+ // Assemble and validate the updated axon state.
336+ prev_axon. block = current_block ;
349337 prev_axon. version = version;
350338 prev_axon. ip = ip;
351339 prev_axon. port = port;
@@ -360,6 +348,6 @@ impl<T: Config> Pallet<T> {
360348 axon_validated. err( ) . unwrap_or( Error :: <T >:: InvalidPort )
361349 ) ;
362350
363- Ok ( ( ) )
351+ Ok ( prev_axon )
364352 }
365353}
0 commit comments