Skip to content

Commit aa19201

Browse files
author
Samuel Dare
committed
chore: make rate limit prettier
1 parent f1866df commit aa19201

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

pallets/subtensor/src/staking/set_children.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -246,23 +246,24 @@ impl<T: Config> Pallet<T> {
246246
Error::<T>::InvalidChildkeyTake
247247
);
248248

249-
// Check if the rate limit has been exceeded
250-
let current_block = Self::get_current_block_as_u64();
251-
let last_tx_block =
252-
Self::get_last_transaction_block(&hotkey, netuid, &TransactionType::SetChildkeyTake);
253-
let rate_limit = TxChildkeyTakeRateLimit::<T>::get();
254-
let passes =
255-
Self::passes_rate_limit_on_subnet(&TransactionType::SetChildkeyTake, &hotkey, netuid);
256-
257-
log::info!(
258-
"Rate limit check: current_block: {}, last_tx_block: {}, rate_limit: {}, passes: {}",
259-
current_block,
260-
last_tx_block,
261-
rate_limit,
262-
passes
249+
// Ensure the hotkey passes the rate limit.
250+
ensure!(
251+
Self::passes_rate_limit_on_subnet(
252+
&TransactionType::SetChildkeyTake, // Set childkey take.
253+
&hotkey, // Specific to a hotkey.
254+
netuid, // Specific to a subnet.
255+
),
256+
Error::<T>::TxChildkeyTakeRateLimitExceeded
263257
);
264258

265-
ensure!(passes, Error::<T>::TxChildkeyTakeRateLimitExceeded);
259+
// Set last transaction block
260+
let current_block = Self::get_current_block_as_u64();
261+
Self::set_last_transaction_block(
262+
&hotkey,
263+
netuid,
264+
&TransactionType::SetChildkeyTake,
265+
current_block
266+
);
266267

267268
// Set the new childkey take value for the given hotkey and network
268269
ChildkeyTake::<T>::insert(hotkey.clone(), netuid, take);

0 commit comments

Comments
 (0)