From 5e45f5c717bbcd663ecdbf9502a4b78bcc3d7535 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Sun, 15 Sep 2024 15:43:03 +0800 Subject: [PATCH] refactor once again --- pallets/subtensor/src/subnets/uids.rs | 15 ++++++++++----- runtime/src/lib.rs | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pallets/subtensor/src/subnets/uids.rs b/pallets/subtensor/src/subnets/uids.rs index 7fb2e1e25..cf9cf1a1f 100644 --- a/pallets/subtensor/src/subnets/uids.rs +++ b/pallets/subtensor/src/subnets/uids.rs @@ -18,11 +18,16 @@ impl Pallet { /// Resets the trust, emission, consensus, incentive, dividends of the neuron to default pub fn clear_neuron(netuid: u16, neuron_uid: u16) { - Emission::::mutate(netuid, |v| Self::set_element_at(v, neuron_uid.into(), 0)); - Trust::::mutate(netuid, |v| Self::set_element_at(v, neuron_uid.into(), 0)); - Consensus::::mutate(netuid, |v| Self::set_element_at(v, neuron_uid.into(), 0)); - Incentive::::mutate(netuid, |v| Self::set_element_at(v, neuron_uid.into(), 0)); - Dividends::::mutate(netuid, |v| Self::set_element_at(v, neuron_uid.into(), 0)); + let neuron_index: usize = neuron_uid.into(); + Self::set_element_at(&mut Emission::::get(netuid), neuron_index, 0); + for storage in &mut [ + &mut Trust::::get(netuid), + &mut Consensus::::get(netuid), + &mut Incentive::::get(netuid), + &mut Dividends::::get(netuid), + ] { + Self::set_element_at(storage, neuron_index, 0); + } } /// Replace the neuron under this uid. diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 9622c6e2a..b7a347c46 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -142,7 +142,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 196, + spec_version: 197, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1,