Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
open-junius committed Sep 20, 2024
1 parent 447f7b7 commit 538b9a7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
39 changes: 21 additions & 18 deletions pallets/subtensor/src/coinbase/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,29 +1241,32 @@ impl<T: Config> Pallet<T> {
///
pub fn get_network_lock_cost() -> u64 {
#[cfg(feature = "pow-faucet")]
return 0_64;
return 0_u64;

let last_lock = Self::get_network_last_lock();
let min_lock = Self::get_network_min_lock();
let last_lock_block = Self::get_network_last_lock_block();
let current_block = Self::get_current_block_as_u64();
let lock_reduction_interval = Self::get_lock_reduction_interval();
let mult = if last_lock_block == 0 { 1 } else { 2 };

let mut lock_cost = last_lock.saturating_mul(mult).saturating_sub(
last_lock
.saturating_div(lock_reduction_interval)
.saturating_mul(current_block.saturating_sub(last_lock_block)),
);
#[cfg(not(feature = "pow-faucet"))]
{
let last_lock = Self::get_network_last_lock();
let min_lock = Self::get_network_min_lock();
let last_lock_block = Self::get_network_last_lock_block();
let current_block = Self::get_current_block_as_u64();
let lock_reduction_interval = Self::get_lock_reduction_interval();
let mult = if last_lock_block == 0 { 1 } else { 2 };

let mut lock_cost = last_lock.saturating_mul(mult).saturating_sub(
last_lock
.saturating_div(lock_reduction_interval)
.saturating_mul(current_block.saturating_sub(last_lock_block)),
);

if lock_cost < min_lock {
lock_cost = min_lock;
}
if lock_cost < min_lock {
lock_cost = min_lock;
}

log::debug!( "last_lock: {:?}, min_lock: {:?}, last_lock_block: {:?}, lock_reduction_interval: {:?}, current_block: {:?}, mult: {:?} lock_cost: {:?}",
log::debug!( "last_lock: {:?}, min_lock: {:?}, last_lock_block: {:?}, lock_reduction_interval: {:?}, current_block: {:?}, mult: {:?} lock_cost: {:?}",
last_lock, min_lock, last_lock_block, lock_reduction_interval, current_block, mult, lock_cost);

lock_cost
lock_cost
}
}

/// This function is used to determine which subnet to prune when the total number of networks has reached the limit.
Expand Down
4 changes: 2 additions & 2 deletions pallets/subtensor/src/macros/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ mod genesis {
if self.initialize_network_1 {
init_network::<T>(1, tempo);
if let Some((coldkey, hotkey)) = &self.subnet_coldkey_validator {
crate::Pallet::<T>::create_account_if_non_existent(&coldkey, &hotkey);
crate::Pallet::<T>::append_neuron(1, &hotkey, 0);
Pallet::<T>::create_account_if_non_existent(&coldkey, &hotkey);
Pallet::<T>::append_neuron(1, &hotkey, 0);
}
}

Expand Down

0 comments on commit 538b9a7

Please sign in to comment.