From ebf4030b175355fc528137ea642b2d2790e49ac7 Mon Sep 17 00:00:00 2001 From: UnArbosSix Date: Thu, 16 Jul 2026 09:10:37 -0700 Subject: [PATCH] reuse canonical alpha iterator in hotkey swap --- pallets/subtensor/src/swap/swap_hotkey.rs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/pallets/subtensor/src/swap/swap_hotkey.rs b/pallets/subtensor/src/swap/swap_hotkey.rs index 96b10d74ea..dce875dc0c 100644 --- a/pallets/subtensor/src/swap/swap_hotkey.rs +++ b/pallets/subtensor/src/swap/swap_hotkey.rs @@ -27,20 +27,8 @@ impl Pallet { /// Read and merge the old hotkey's V1/V2 stake rows once. V2 keeps the /// existing precedence over a duplicate legacy row. fn prepare_hotkey_stake(old_hotkey: &T::AccountId) -> PreparedHotkeyStake { - let mut merged: BTreeMap<(T::AccountId, NetUid), SafeFloat> = BTreeMap::new(); - - for ((coldkey, netuid), alpha) in Alpha::::iter_prefix((old_hotkey,)) { - merged.insert((coldkey, netuid), alpha.into()); - } - - for ((coldkey, netuid), alpha) in AlphaV2::::iter_prefix((old_hotkey,)) { - merged.insert((coldkey, netuid), alpha); - } - - let positions: Vec<(T::AccountId, NetUid, SafeFloat)> = merged - .into_iter() - .map(|((coldkey, netuid), alpha)| (coldkey, netuid, alpha)) - .collect(); + let positions: Vec<(T::AccountId, NetUid, SafeFloat)> = + Self::alpha_iter_single_prefix(old_hotkey).collect(); let mut coldkeys_by_netuid: BTreeMap> = BTreeMap::new(); for (coldkey, netuid, _) in &positions {