Skip to content

Commit 5f9a9e0

Browse files
committed
fix: comment
1 parent aea45a7 commit 5f9a9e0

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

pallets/subtensor/src/staking.rs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ impl<T: Config> Pallet<T> {
189189
}
190190

191191
// --- 8. Ensure the remove operation from the coldkey is a success.
192-
let actual_amount_to_stake = Self::remove_balance_from_coldkey_account(&coldkey, stake_as_balance.unwrap())?;
192+
let actual_amount_to_stake =
193+
Self::remove_balance_from_coldkey_account(&coldkey, stake_as_balance.unwrap())?;
193194

194195
// --- 9. If we reach here, add the balance to the hotkey.
195196
Self::increase_stake_on_coldkey_hotkey_account(&coldkey, &hotkey, actual_amount_to_stake);
@@ -198,7 +199,7 @@ impl<T: Config> Pallet<T> {
198199
let block: u64 = Self::get_current_block_as_u64();
199200
Self::set_last_tx_block(&coldkey, block);
200201

201-
// --- 9. Emit the staking event.
202+
// --- 10. Emit the staking event.
202203
Self::set_stakes_this_interval_for_coldkey_hotkey(
203204
&coldkey,
204205
&hotkey,
@@ -212,7 +213,7 @@ impl<T: Config> Pallet<T> {
212213
);
213214
Self::deposit_event(Event::StakeAdded(hotkey, actual_amount_to_stake));
214215

215-
// --- 10. Ok and return.
216+
// --- 11. Ok and return.
216217
Ok(())
217218
}
218219

@@ -587,7 +588,7 @@ impl<T: Config> Pallet<T> {
587588
input: u64,
588589
) -> Option<
589590
<<T as Config>::Currency as fungible::Inspect<<T as frame_system::Config>::AccountId>>::Balance,
590-
> {
591+
>{
591592
input.try_into().ok()
592593
}
593594

@@ -616,48 +617,45 @@ impl<T: Config> Pallet<T> {
616617
}
617618

618619
// This bit is currently untested. @todo
619-
620-
T::Currency::can_withdraw(
621-
coldkey,
622-
amount,
623-
)
624-
.into_result(false)
625-
.is_ok()
620+
621+
T::Currency::can_withdraw(coldkey, amount)
622+
.into_result(false)
623+
.is_ok()
626624
}
627625

628626
pub fn get_coldkey_balance(
629627
coldkey: &T::AccountId,
630628
) -> <<T as Config>::Currency as fungible::Inspect<<T as system::Config>::AccountId>>::Balance
631629
{
632-
T::Currency::reducible_balance(
633-
coldkey,
634-
Preservation::Expendable,
635-
Fortitude::Polite,
636-
)
630+
T::Currency::reducible_balance(coldkey, Preservation::Expendable, Fortitude::Polite)
637631
}
638632

639633
#[must_use = "Balance must be used to preserve total issuance of token"]
640634
pub fn remove_balance_from_coldkey_account(
641635
coldkey: &T::AccountId,
642636
amount: <<T as Config>::Currency as fungible::Inspect<<T as system::Config>::AccountId>>::Balance,
643637
) -> Result<u64, DispatchError> {
644-
let amount_u64: u64 = amount.try_into().map_err(|_| Error::<T>::CouldNotConvertToU64)?;
638+
let amount_u64: u64 = amount
639+
.try_into()
640+
.map_err(|_| Error::<T>::CouldNotConvertToU64)?;
645641

646642
if amount_u64 == 0 {
647643
return Ok(0);
648644
}
649645

650646
let credit = T::Currency::withdraw(
651-
coldkey,
652-
amount,
653-
Precision::BestEffort,
654-
Preservation::Preserve,
655-
Fortitude::Polite,
656-
)
657-
.map_err(|_| Error::<T>::BalanceWithdrawalError)?
658-
.peek();
647+
coldkey,
648+
amount,
649+
Precision::BestEffort,
650+
Preservation::Preserve,
651+
Fortitude::Polite,
652+
)
653+
.map_err(|_| Error::<T>::BalanceWithdrawalError)?
654+
.peek();
659655

660-
let credit_u64: u64 = credit.try_into().map_err(|_| Error::<T>::CouldNotConvertToU64)?;
656+
let credit_u64: u64 = credit
657+
.try_into()
658+
.map_err(|_| Error::<T>::CouldNotConvertToU64)?;
661659

662660
if credit_u64 == 0 {
663661
return Err(Error::<T>::BalanceWithdrawalError.into());

0 commit comments

Comments
 (0)