mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 04:25:42 +00:00
Refactor: fixed point arithmetic for SRML. (#3456)
* Macro-ify perthings. * Refactor fixed64 * Half-workign phragmen refactor. * Finalize phragmen refactor. * Fix creation of perquintill * Fix build errors * Line-width * Fix more build errors. * Line-width * Fix offence test * Resolve all TODOs. * Apply suggestions from code review Co-Authored-By: Gavin Wood <gavin@parity.io> Co-Authored-By: thiolliere <gui.thiolliere@gmail.com> * Fix most of the review comments. * Updates to multiply by rational * Fxi build * Fix abs issue with Fixed64 * Fix tests and improvements. * Fix build * Remove more tests from staking. * Review comments. * Add fuzzing stuff. * Better fuzzing * Better doc. * Bump. * Master.into() * A bit more hardening. * Final nits. * Update lock * Fix indent. * Revert lock file. * Bump.
This commit is contained in:
@@ -33,7 +33,7 @@ use support::{
|
||||
};
|
||||
use sr_primitives::{
|
||||
Perbill,
|
||||
traits::Hash,
|
||||
traits::{Hash, Saturating},
|
||||
};
|
||||
use sr_staking_primitives::{
|
||||
offence::{Offence, ReportOffence, Kind, OnOffenceHandler, OffenceDetails},
|
||||
@@ -131,12 +131,9 @@ where
|
||||
offenders_count.saturating_sub(previous_offenders_count),
|
||||
validator_set_count,
|
||||
);
|
||||
let numerator = new_fraction
|
||||
.into_parts()
|
||||
.saturating_sub(previous_fraction.into_parts());
|
||||
let denominator =
|
||||
Perbill::from_parts(Perbill::one().into_parts() - previous_fraction.into_parts());
|
||||
Perbill::from_parts(denominator * numerator)
|
||||
let numerator = new_fraction.saturating_sub(previous_fraction);
|
||||
let denominator = Perbill::one().saturating_sub(previous_fraction);
|
||||
denominator.saturating_mul(numerator)
|
||||
} else {
|
||||
new_fraction.clone()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user