Skip to content

Commit cfc0b9f

Browse files
committed
Bring back is_registration_allowed
1 parent 2f79f2e commit cfc0b9f

File tree

1 file changed

+19
-0
lines changed
  • pallets/subtensor/src/coinbase

1 file changed

+19
-0
lines changed

pallets/subtensor/src/coinbase/root.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,25 @@ impl<T: Config> Pallet<T> {
299299
Self::deposit_event(Event::NetworkRateLimitSet(limit));
300300
}
301301

302+
/// Checks if registrations are allowed for a given subnet.
303+
///
304+
/// This function retrieves the subnet hyperparameters for the specified subnet and checks the
305+
/// `registration_allowed` flag. If the subnet doesn't exist or doesn't have hyperparameters
306+
/// defined, it returns `false`.
307+
///
308+
/// # Arguments
309+
///
310+
/// * `netuid` - The unique identifier of the subnet.
311+
///
312+
/// # Returns
313+
///
314+
/// * `bool` - `true` if registrations are allowed for the subnet, `false` otherwise.
315+
pub fn is_registration_allowed(netuid: u16) -> bool {
316+
Self::get_subnet_hyperparams(netuid)
317+
.map(|params| params.registration_allowed)
318+
.unwrap_or(false)
319+
}
320+
302321
/// Computes and sets emission values for the root network which determine the emission for all subnets.
303322
///
304323
/// This function is responsible for calculating emission based on network weights, stake values,

0 commit comments

Comments
 (0)