Skip to content

Commit 5e45f5c

Browse files
refactor once again
1 parent 6575d97 commit 5e45f5c

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

pallets/subtensor/src/subnets/uids.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@ impl<T: Config> Pallet<T> {
1818

1919
/// Resets the trust, emission, consensus, incentive, dividends of the neuron to default
2020
pub fn clear_neuron(netuid: u16, neuron_uid: u16) {
21-
Emission::<T>::mutate(netuid, |v| Self::set_element_at(v, neuron_uid.into(), 0));
22-
Trust::<T>::mutate(netuid, |v| Self::set_element_at(v, neuron_uid.into(), 0));
23-
Consensus::<T>::mutate(netuid, |v| Self::set_element_at(v, neuron_uid.into(), 0));
24-
Incentive::<T>::mutate(netuid, |v| Self::set_element_at(v, neuron_uid.into(), 0));
25-
Dividends::<T>::mutate(netuid, |v| Self::set_element_at(v, neuron_uid.into(), 0));
21+
let neuron_index: usize = neuron_uid.into();
22+
Self::set_element_at(&mut Emission::<T>::get(netuid), neuron_index, 0);
23+
for storage in &mut [
24+
&mut Trust::<T>::get(netuid),
25+
&mut Consensus::<T>::get(netuid),
26+
&mut Incentive::<T>::get(netuid),
27+
&mut Dividends::<T>::get(netuid),
28+
] {
29+
Self::set_element_at(storage, neuron_index, 0);
30+
}
2631
}
2732

2833
/// Replace the neuron under this uid.

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
142142
// `spec_version`, and `authoring_version` are the same between Wasm and native.
143143
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
144144
// the compatible custom types.
145-
spec_version: 196,
145+
spec_version: 197,
146146
impl_version: 1,
147147
apis: RUNTIME_API_VERSIONS,
148148
transaction_version: 1,

0 commit comments

Comments
 (0)