Skip to content

Commit

Permalink
Use alpha for stake in neuron info
Browse files Browse the repository at this point in the history
  • Loading branch information
ales-otf committed Oct 30, 2024
1 parent 4148c3a commit 55f19af
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
19 changes: 10 additions & 9 deletions pallets/subtensor/src/rpc_info/neuron_info.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::*;
use frame_support::pallet_prelude::{Decode, Encode};
use frame_support::storage::IterableStorageDoubleMap;
extern crate alloc;
use codec::Compact;

Expand Down Expand Up @@ -117,8 +116,12 @@ impl<T: Config> Pallet<T> {
}
})
.collect::<Vec<(Compact<u16>, Compact<u16>)>>();
let stake_weight: u64 = Self::get_stake_weight(netuid, uid) as u64;
let stake: Vec<(T::AccountId, Compact<u64>)> = vec![(coldkey.clone(), stake_weight.into())];

let stake: Vec<(T::AccountId, Compact<u64>)> = vec![(
coldkey.clone(),
Alpha::<T>::get((&hotkey, coldkey.clone(), netuid)).into(),
)];

let neuron = NeuronInfo {
hotkey: hotkey.clone(),
coldkey: coldkey.clone(),
Expand Down Expand Up @@ -177,12 +180,10 @@ impl<T: Config> Pallet<T> {
let last_update = Self::get_last_update_for_uid(netuid, uid);
let validator_permit = Self::get_validator_permit_for_uid(netuid, uid);

let stake: Vec<(T::AccountId, Compact<u64>)> =
<Stake<T> as IterableStorageDoubleMap<T::AccountId, T::AccountId, u64>>::iter_prefix(
hotkey.clone(),
)
.map(|(coldkey, stake)| (coldkey, stake.into()))
.collect();
let stake: Vec<(T::AccountId, Compact<u64>)> = vec![(
coldkey.clone(),
Alpha::<T>::get((&hotkey, coldkey.clone(), netuid)).into(),
)];

let neuron = NeuronInfoLite {
hotkey: hotkey.clone(),
Expand Down
18 changes: 9 additions & 9 deletions pallets/subtensor/src/rpc_info/stake_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ impl<T: Config> Pallet<T> {
}
let netuids: Vec<u16> = Self::get_all_subnet_netuids();
let mut stake_info: Vec<(T::AccountId, Vec<StakeInfo<T>>)> = Vec::new();
for coldkey_i in coldkeys.clone().iter() {
for coldkey_i in coldkeys.iter() {
// Get all hotkeys associated with this coldkey.
let staking_hotkeys = StakingHotkeys::<T>::get(coldkey_i.clone());
let staking_hotkeys = StakingHotkeys::<T>::get(coldkey_i);
let mut stake_info_for_coldkey: Vec<StakeInfo<T>> = Vec::new();
for netuid_i in netuids.clone().iter() {
for hotkey_i in staking_hotkeys.clone().iter() {
for netuid_i in netuids.iter() {
for hotkey_i in staking_hotkeys.iter() {
let alpha: u64 =
Alpha::<T>::get((hotkey_i.clone(), coldkey_i.clone(), netuid_i));
Alpha::<T>::get((hotkey_i, coldkey_i, netuid_i));
let emission: u64 = LastHotkeyColdkeyEmissionOnNetuid::<T>::get((
hotkey_i.clone(),
coldkey_i.clone(),
hotkey_i,
coldkey_i,
*netuid_i,
));
let drain: u64 = LastHotkeyEmissionDrain::<T>::get(hotkey_i.clone());
let drain: u64 = LastHotkeyEmissionDrain::<T>::get(hotkey_i);
let is_registered: bool =
Self::is_hotkey_registered_on_network(*netuid_i, &hotkey_i);
Self::is_hotkey_registered_on_network(*netuid_i, hotkey_i);
stake_info_for_coldkey.push(StakeInfo {
hotkey: hotkey_i.clone(),
coldkey: coldkey_i.clone(),
Expand Down

0 comments on commit 55f19af

Please sign in to comment.