Skip to content

Commit

Permalink
Use passes_rate_limit_on_subnet for setting children
Browse files Browse the repository at this point in the history
  • Loading branch information
gztensor committed Aug 16, 2024
1 parent ce0dfa7 commit d6790a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pallets/subtensor/src/staking/set_children.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ impl<T: Config> Pallet<T> {

// Ensure the hotkey passes the rate limit.
ensure!(
Self::passes_rate_limit_globally(
Self::passes_rate_limit_on_subnet(
&TransactionType::SetChildren, // Set children.
&hotkey, // Specific to a hotkey.
netuid, // Specific to a subnet.
&TransactionType::SetChildren, // Set children.
),
Error::<T>::TxRateLimitExceeded
);
Expand Down
7 changes: 2 additions & 5 deletions pallets/subtensor/src/utils/rate_limiting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,8 @@ impl<T: Config> Pallet<T> {
}

/// Check if a transaction should be rate limited globally
pub fn passes_rate_limit_globally(
hotkey: &T::AccountId,
netuid: u16,
tx_type: &TransactionType,
) -> bool {
pub fn passes_rate_limit_globally(tx_type: &TransactionType, hotkey: &T::AccountId) -> bool {
let netuid: u16 = u16::MAX;
let block: u64 = Self::get_current_block_as_u64();
let limit: u64 = Self::get_rate_limit(tx_type);
let last_block: u64 = Self::get_last_transaction_block(hotkey, netuid, tx_type);
Expand Down

0 comments on commit d6790a3

Please sign in to comment.