Skip to content

Commit 4726ec3

Browse files
committed
fix divide by zero
1 parent 28ba654 commit 4726ec3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pallets/subtensor/src/coinbase/run_coinbase.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ impl<T: Config> Pallet<T> {
299299
// --- 10 Calculate this nominator's share of the emission.
300300
let nominator_emission: I64F64 = I64F64::from_num(emission_minus_take)
301301
.saturating_mul(I64F64::from_num(nominator_stake))
302-
.saturating_div(I64F64::from_num(total_hotkey_stake));
302+
.check_div(I64F64::from_num(total_hotkey_stake))
303+
.unwrap_or(I64F64::from_num(0));
303304

304305
// --- 11 Increase the stake for the nominator.
305306
Self::increase_stake_on_coldkey_hotkey_account(

0 commit comments

Comments
 (0)