try_from -> from

This commit is contained in:
Luke Parker 2023-11-06 17:00:09 -05:00
parent df8b455d54
commit 205bec36e5
No known key found for this signature in database

View file

@ -99,11 +99,9 @@ pub fn set_keys_message(set: &ValidatorSet, key_pair: &KeyPair) -> Vec<u8> {
/// 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::<u16>();
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;
}
}