Fix the broken weight multiplier update function (#6334)

* Initial draft, has some todos left

* remove ununsed import

* Apply suggestions from code review

* Some refactors with migration

* Fix more test and cleanup

* Fix for companion

* Apply suggestions from code review

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update bin/node/runtime/src/impls.rs

* Fix weight

* Add integrity test

* length is not affected.

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
This commit is contained in:
Kian PaimaniandAlexander Popiak authored and GitHub committed 2020-06-17 13:20:17 +00:00
1 parent 67c9ac9393
commit 82bdf1a891
10 files changed
+458 -253

No files matched your search

@@ -372,6 +372,23 @@ macro_rules! implement_fixed {
}
}
impl $name {
/// const version of `FixedPointNumber::from_inner`.
pub const fn from_inner(inner: $inner_type) -> Self {
Self(inner)
}
#[cfg(any(feature = "std", test))]
pub fn from_fraction(x: f64) -> Self {
Self((x * (<Self as FixedPointNumber>::DIV as f64)) as $inner_type)
}
#[cfg(any(feature = "std", test))]
pub fn to_fraction(self) -> f64 {
self.0 as f64 / <Self as FixedPointNumber>::DIV as f64
}
}
impl Saturating for $name {
fn saturating_add(self, rhs: Self) -> Self {
Self(self.0.saturating_add(rhs.0))