Skip to content

Commit 5a0236a

Browse files
committed
use bool return type
1 parent 392fce3 commit 5a0236a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

pallets/subtensor/src/staking/stake_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ impl<T: Config> Pallet<T> {
553553
hotkey: &T::AccountId,
554554
netuid: u16,
555555
amount: u64,
556-
) -> Result<(), ()> {
556+
) -> bool {
557557
let mut alpha_share_pool = Self::get_alpha_share_pool(hotkey.clone(), netuid);
558558
alpha_share_pool.sim_update_value_for_one(amount as i64)
559559
}
@@ -895,9 +895,9 @@ impl<T: Config> Pallet<T> {
895895
let try_stake_result = Self::try_increase_stake_for_hotkey_and_coldkey_on_subnet(
896896
hotkey,
897897
netuid,
898-
expected_alpha.unwrap(),
898+
expected_alpha.unwrap_or(0),
899899
);
900-
ensure!(try_stake_result.is_ok(), Error::<T>::InsufficientLiquidity);
900+
ensure!(try_stake_result, Error::<T>::InsufficientLiquidity);
901901

902902
Ok(())
903903
}
@@ -1019,7 +1019,7 @@ impl<T: Config> Pallet<T> {
10191019
destination_netuid,
10201020
expected_alpha,
10211021
);
1022-
ensure!(try_stake_result.is_ok(), Error::<T>::InsufficientLiquidity);
1022+
ensure!(try_stake_result, Error::<T>::InsufficientLiquidity);
10231023

10241024
if check_transfer_toggle {
10251025
// Ensure transfer is toggled.

primitives/share-pool/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ where
7575
});
7676
}
7777

78-
pub fn sim_update_value_for_one(&mut self, update: i64) -> Result<(), ()> {
78+
pub fn sim_update_value_for_one(&mut self, update: i64) -> bool {
7979
let shared_value: U64F64 = self.state_ops.get_shared_value();
8080
let denominator: U64F64 = self.state_ops.get_denominator();
8181

8282
// Then, update this key's share
8383
if denominator == 0 {
84-
Ok(())
84+
true
8585
} else {
8686
// There are already keys in the pool, set or update this key
8787
let value_per_share: I64F64 = I64F64::saturating_from_num(
@@ -95,9 +95,9 @@ where
9595
.unwrap_or(I64F64::saturating_from_num(0));
9696

9797
if shares_per_update != 0 {
98-
Ok(())
98+
true
9999
} else {
100-
Err(())
100+
false
101101
}
102102
}
103103
}

0 commit comments

Comments
 (0)