Skip to content

Commit 776d886

Browse files
committed
add stake amount to priority
1 parent dbbfb61 commit 776d886

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

pallets/subtensor/src/lib.rs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,15 +1601,21 @@ pub mod pallet {
16011601
}
16021602

16031603
/// Returns the transaction priority for stake operations.
1604-
pub fn get_priority_staking(coldkey: &T::AccountId, hotkey: &T::AccountId) -> u64 {
1604+
pub fn get_priority_staking(
1605+
coldkey: &T::AccountId,
1606+
hotkey: &T::AccountId,
1607+
stake_amount: u64,
1608+
) -> u64 {
16051609
match LastColdkeyHotkeyStakeBlock::<T>::get(coldkey, hotkey) {
16061610
Some(last_stake_block) => {
16071611
let current_block_number = Self::get_current_block_as_u64();
16081612
let default_priority = current_block_number.saturating_sub(last_stake_block);
16091613

1610-
default_priority.saturating_add(u32::MAX as u64)
1614+
default_priority
1615+
.saturating_add(u32::MAX as u64)
1616+
.saturating_add(stake_amount)
16111617
}
1612-
None => 0,
1618+
None => stake_amount,
16131619
}
16141620
}
16151621

@@ -1738,8 +1744,12 @@ where
17381744
Pallet::<T>::get_priority_set_weights(who, netuid)
17391745
}
17401746

1741-
pub fn get_priority_staking(coldkey: &T::AccountId, hotkey: &T::AccountId) -> u64 {
1742-
Pallet::<T>::get_priority_staking(coldkey, hotkey)
1747+
pub fn get_priority_staking(
1748+
coldkey: &T::AccountId,
1749+
hotkey: &T::AccountId,
1750+
stake_amount: u64,
1751+
) -> u64 {
1752+
Pallet::<T>::get_priority_staking(coldkey, hotkey, stake_amount)
17431753
}
17441754

17451755
pub fn check_weights_min_stake(who: &T::AccountId, netuid: u16) -> bool {
@@ -1954,7 +1964,7 @@ where
19541964
*amount_staked,
19551965
false,
19561966
),
1957-
Self::get_priority_staking(who, hotkey),
1967+
Self::get_priority_staking(who, hotkey, *amount_staked),
19581968
)
19591969
}
19601970
Some(Call::add_stake_limit {
@@ -1984,7 +1994,7 @@ where
19841994
max_amount,
19851995
*allow_partial,
19861996
),
1987-
Self::get_priority_staking(who, hotkey),
1997+
Self::get_priority_staking(who, hotkey, *amount_staked),
19881998
)
19891999
}
19902000
Some(Call::remove_stake {
@@ -2002,7 +2012,7 @@ where
20022012
*amount_unstaked,
20032013
false,
20042014
),
2005-
Self::get_priority_staking(who, hotkey),
2015+
Self::get_priority_staking(who, hotkey, *amount_unstaked),
20062016
)
20072017
}
20082018
Some(Call::remove_stake_limit {
@@ -2025,7 +2035,7 @@ where
20252035
max_amount,
20262036
*allow_partial,
20272037
),
2028-
Self::get_priority_staking(who, hotkey),
2038+
Self::get_priority_staking(who, hotkey, *amount_unstaked),
20292039
)
20302040
}
20312041
Some(Call::move_stake {
@@ -2056,7 +2066,7 @@ where
20562066
None,
20572067
false,
20582068
),
2059-
Self::get_priority_staking(who, origin_hotkey),
2069+
Self::get_priority_staking(who, origin_hotkey, *alpha_amount),
20602070
)
20612071
}
20622072
Some(Call::transfer_stake {
@@ -2087,7 +2097,7 @@ where
20872097
None,
20882098
true,
20892099
),
2090-
Self::get_priority_staking(who, hotkey),
2100+
Self::get_priority_staking(who, hotkey, *alpha_amount),
20912101
)
20922102
}
20932103
Some(Call::swap_stake {
@@ -2117,7 +2127,7 @@ where
21172127
None,
21182128
false,
21192129
),
2120-
Self::get_priority_staking(who, hotkey),
2130+
Self::get_priority_staking(who, hotkey, *alpha_amount),
21212131
)
21222132
}
21232133
Some(Call::swap_stake_limit {
@@ -2156,7 +2166,7 @@ where
21562166
Some(*allow_partial),
21572167
false,
21582168
),
2159-
Self::get_priority_staking(who, hotkey),
2169+
Self::get_priority_staking(who, hotkey, *alpha_amount),
21602170
)
21612171
}
21622172
Some(Call::register { netuid, .. } | Call::burned_register { netuid, .. }) => {

0 commit comments

Comments
 (0)