Skip to content

Commit 1ffefe1

Browse files
committed
Fix unsafe math
1 parent 3eca45f commit 1ffefe1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pallets/subtensor/src/coinbase/run_coinbase.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<T: Config> Pallet<T> {
4545
log::debug!("All subnet netuids: {:?}", subnets);
4646

4747
// --- 2. Get sum of tao reserves ( in a later version we will switch to prices. )
48-
let mut total_moving_prices: I96F32 = I96F32::from_num(0.0);
48+
let mut total_moving_prices: I96F32 = I96F32::saturating_from_num(0.0);
4949
for netuid_i in subnets.iter() {
5050
// Get and update the moving price of each subnet adding the total together.
5151
total_moving_prices =

pallets/subtensor/src/staking/helpers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ impl<T: Config> Pallet<T> {
121121
Delegates::<T>::get(hotkey)
122122
}
123123
pub fn get_hotkey_take_float(hotkey: &T::AccountId) -> I96F32 {
124-
I96F32::from_num(Self::get_hotkey_take(hotkey))
125-
.checked_div(I96F32::from_num(u16::MAX))
126-
.unwrap_or(I96F32::from_num(0.0))
124+
I96F32::saturating_from_num(Self::get_hotkey_take(hotkey))
125+
.checked_div(I96F32::saturating_from_num(u16::MAX))
126+
.unwrap_or(I96F32::saturating_from_num(0.0))
127127
}
128128

129129
/// Returns true if the hotkey account has been created.

0 commit comments

Comments
 (0)