|
1 | 1 | use super::*; |
2 | 2 | use crate::epoch::math::safe_modulo; |
3 | 3 | use alloc::collections::BTreeMap; |
| 4 | +use subnets::Mechanism; |
4 | 5 | use substrate_fixed::types::I96F32; |
5 | 6 |
|
6 | 7 | impl<T: Config> Pallet<T> { |
@@ -28,7 +29,7 @@ impl<T: Config> Pallet<T> { |
28 | 29 |
|
29 | 30 | // --- 4. Sum all the SubnetTAO associated with the same mechanism |
30 | 31 | let mut total_active_tao: I96F32 = I96F32::from_num(0); |
31 | | - let mut mechanism_tao: BTreeMap<u16, I96F32> = BTreeMap::new(); |
| 32 | + let mut mechanism_tao: BTreeMap<Mechanism, I96F32> = BTreeMap::new(); |
32 | 33 | for netuid in subnets.iter() { |
33 | 34 | if *netuid == 0 { |
34 | 35 | continue; |
@@ -63,7 +64,7 @@ impl<T: Config> Pallet<T> { |
63 | 64 | continue; |
64 | 65 | } |
65 | 66 | // 1. Get subnet mechanism ID |
66 | | - let mechid: u16 = SubnetMechanism::<T>::get(*netuid); |
| 67 | + let mechid: Mechanism = SubnetMechanism::<T>::get(*netuid); |
67 | 68 | // 2. Get subnet TAO (T_s) |
68 | 69 | let subnet_tao: I96F32 = I96F32::from_num(SubnetTAO::<T>::get(*netuid)); |
69 | 70 | // 3. Get the denominator as the sum of all TAO associated with a specific mechanism (T_m) |
@@ -94,7 +95,7 @@ impl<T: Config> Pallet<T> { |
94 | 95 | // 11. Increase total issuance: I_new = I_old + E_s |
95 | 96 | TotalIssuance::<T>::mutate(|total| *total = total.saturating_add(subnet_emission)); |
96 | 97 | // 12. Switch on dynamic or Stable. |
97 | | - if mechid == 1 { |
| 98 | + if mechid.is_dynamic() { |
98 | 99 | // 12a Dynamic: Add the SubnetAlpha directly into the pool immediately: A_s_new = A_s_old + E_m |
99 | 100 | SubnetAlphaIn::<T>::mutate(*netuid, |total| { |
100 | 101 | *total = total.saturating_add(block_emission.to_num::<u64>()) |
|
0 commit comments