From 205bec36e561bb9f23256dd7d2d84d5c96236a0c Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Mon, 6 Nov 2023 17:00:09 -0500 Subject: [PATCH] try_from -> from --- substrate/validator-sets/primitives/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/substrate/validator-sets/primitives/src/lib.rs b/substrate/validator-sets/primitives/src/lib.rs index d3acad10..7485c511 100644 --- a/substrate/validator-sets/primitives/src/lib.rs +++ b/substrate/validator-sets/primitives/src/lib.rs @@ -99,11 +99,9 @@ pub fn set_keys_message(set: &ValidatorSet, key_pair: &KeyPair) -> Vec { /// Reduction occurs by reducing each validator in a reverse round-robin. pub fn amortize_excess_key_shares(validators: &mut [(Public, u16)]) { let total_key_shares = validators.iter().map(|(_, shares)| shares).sum::(); - for i in 0 .. usize::try_from( + for i in 0 .. usize::from( total_key_shares.saturating_sub(u16::try_from(MAX_KEY_SHARES_PER_SET).unwrap()), - ) - .unwrap() - { + ) { validators[validators.len() - ((i % validators.len()) + 1)].1 -= 1; } }