Skip to content

Commit 2aad6fe

Browse files
cleanup get_neuron_certificate
1 parent 05d0d8d commit 2aad6fe

File tree

4 files changed

+6
-27
lines changed

4 files changed

+6
-27
lines changed

pallets/subtensor/src/rpc_info/neuron_info.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,6 @@ impl<T: Config> Pallet<T> {
147147
Some(neuron)
148148
}
149149

150-
pub fn get_neuron_certificate(netuid: u16, uid: u16) -> Option<NeuronCertificate> {
151-
if !Self::if_subnet_exist(netuid) {
152-
return None;
153-
}
154-
155-
let hotkey = match Self::get_hotkey_for_net_and_uid(netuid, uid) {
156-
Ok(h) => h,
157-
Err(_) => return None,
158-
};
159-
160-
if Self::has_neuron_certificate(netuid, &hotkey) {
161-
NeuronCertificates::<T>::get(netuid, hotkey)
162-
} else {
163-
None
164-
}
165-
}
166-
167150
pub fn get_neuron(netuid: u16, uid: u16) -> Option<NeuronInfo<T>> {
168151
if !Self::if_subnet_exist(netuid) {
169152
return None;

pallets/subtensor/src/subnets/serving.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,6 @@ impl<T: Config> Pallet<T> {
252252
Axons::<T>::contains_key(netuid, hotkey)
253253
}
254254

255-
pub fn has_neuron_certificate(netuid: u16, hotkey: &T::AccountId) -> bool {
256-
NeuronCertificates::<T>::contains_key(netuid, hotkey)
257-
}
258-
259255
pub fn has_prometheus_info(netuid: u16, hotkey: &T::AccountId) -> bool {
260256
Prometheus::<T>::contains_key(netuid, hotkey)
261257
}

pallets/subtensor/tests/serving.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ fn test_serving_ok() {
103103
fn test_serving_tls_ok() {
104104
new_test_ext(1).execute_with(|| {
105105
let hotkey_account_id = U256::from(1);
106-
let uid: u16 = 0;
107106
let netuid: u16 = 1;
108107
let tempo: u16 = 13;
109108
let version: u32 = 2;
@@ -129,8 +128,9 @@ fn test_serving_tls_ok() {
129128
placeholder2,
130129
certificate.clone()
131130
));
132-
let stored_certificate =
133-
SubtensorModule::get_neuron_certificate(netuid, uid).expect("Certificate should exist");
131+
132+
let stored_certificate = NeuronCertificates::<Test>::get(netuid, hotkey_account_id)
133+
.expect("Certificate should exist");
134134
assert_eq!(stored_certificate.certificate, certificate);
135135
let new_certificate = "UPDATED_CERT".as_bytes().to_vec();
136136
assert_ok!(SubtensorModule::serve_axon_tls(
@@ -145,8 +145,8 @@ fn test_serving_tls_ok() {
145145
placeholder2,
146146
new_certificate.clone()
147147
));
148-
let stored_certificate =
149-
SubtensorModule::get_neuron_certificate(netuid, uid).expect("Certificate should exist");
148+
let stored_certificate = NeuronCertificates::<Test>::get(netuid, hotkey_account_id)
149+
.expect("Certificate should exist");
150150
assert_eq!(stored_certificate.certificate, new_certificate)
151151
});
152152
}

pallets/subtensor/tests/uids.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn test_replace_neuron() {
8686
assert_eq!(curr_hotkey.unwrap(), new_hotkey_account_id);
8787

8888
// Check neuron certificate was reset
89-
let certificate = SubtensorModule::get_neuron_certificate(netuid, neuron_uid.unwrap());
89+
let certificate = NeuronCertificates::<Test>::get(netuid, hotkey_account_id);
9090
assert_eq!(certificate, None);
9191
});
9292
}

0 commit comments

Comments
 (0)