mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 02:17:58 +00:00
* Fixed point methods renames. * Bump Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Gav Wood <gavin@parity.io>
This commit is contained in:
Generated
+132
-133
File diff suppressed because it is too large
Load Diff
@@ -16,9 +16,8 @@
|
||||
|
||||
//! Auxillary struct/enums for polkadot runtime.
|
||||
|
||||
use core::num::NonZeroI128;
|
||||
use sp_runtime::traits::{Convert, Saturating};
|
||||
use sp_runtime::{Fixed128, Perquintill};
|
||||
use sp_runtime::{FixedPointNumber, Fixed128, Perquintill};
|
||||
use frame_support::traits::{OnUnbalanced, Imbalance, Currency, Get};
|
||||
use crate::{MaximumBlockWeight, NegativeImbalance};
|
||||
|
||||
@@ -95,17 +94,14 @@ impl<T: Get<Perquintill>, R: system::Trait> Convert<Fixed128, Fixed128> for Targ
|
||||
let positive = block_weight >= target_weight;
|
||||
let diff_abs = block_weight.max(target_weight) - block_weight.min(target_weight);
|
||||
// safe, diff_abs cannot exceed u64 and it can always be computed safely even with the lossy
|
||||
// `Fixed128::from_rational`.
|
||||
let diff = Fixed128::from_rational(
|
||||
diff_abs as i128,
|
||||
NonZeroI128::new(max_weight.max(1) as i128).unwrap(),
|
||||
);
|
||||
// `Fixed128::saturating_from_rational`.
|
||||
let diff = Fixed128::saturating_from_rational(diff_abs, max_weight.max(1));
|
||||
let diff_squared = diff.saturating_mul(diff);
|
||||
|
||||
// 0.00004 = 4/100_000 = 40_000/10^9
|
||||
let v = Fixed128::from_rational(4, NonZeroI128::new(100_000).unwrap());
|
||||
let v = Fixed128::saturating_from_rational(4, 100_000);
|
||||
// 0.00004^2 = 16/10^10 Taking the future /2 into account... 8/10^10
|
||||
let v_squared_2 = Fixed128::from_rational(8, NonZeroI128::new(10_000_000_000).unwrap());
|
||||
let v_squared_2 = Fixed128::saturating_from_rational(8, 10_000_000_000u64);
|
||||
|
||||
let first_term = v.saturating_mul(diff);
|
||||
let second_term = v_squared_2.saturating_mul(diff_squared);
|
||||
@@ -124,7 +120,7 @@ impl<T: Get<Perquintill>, R: system::Trait> Convert<Fixed128, Fixed128> for Targ
|
||||
// multiplier. While at -1, it means that the network is so un-congested that all
|
||||
// transactions have no weight fee. We stop here and only increase if the network
|
||||
// became more busy.
|
||||
.max(Fixed128::from_natural(-1))
|
||||
.max(Fixed128::saturating_from_integer(-1))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user