mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-16 13:11:15 +00:00
Run cargo fmt on the whole code base (#9394)
* Run cargo fmt on the whole code base * Second run * Add CI check * Fix compilation * More unnecessary braces * Handle weights * Use --all * Use correct attributes... * Fix UI tests * AHHHHHHHHH * 🤦 * Docs * Fix compilation * 🤷 * Please stop * 🤦 x 2 * More * make rustfmt.toml consistent with polkadot Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
//! The staking rate in NPoS is the total amount of tokens staked by nominators and validators,
|
||||
//! divided by the total token supply.
|
||||
|
||||
use sp_runtime::{Perbill, traits::AtLeast32BitUnsigned, curve::PiecewiseLinear};
|
||||
use sp_runtime::{curve::PiecewiseLinear, traits::AtLeast32BitUnsigned, Perbill};
|
||||
|
||||
/// The total payout to all validators (and their nominators) per era and maximum payout.
|
||||
///
|
||||
@@ -33,16 +33,18 @@ pub fn compute_total_payout<N>(
|
||||
yearly_inflation: &PiecewiseLinear<'static>,
|
||||
npos_token_staked: N,
|
||||
total_tokens: N,
|
||||
era_duration: u64
|
||||
) -> (N, N) where N: AtLeast32BitUnsigned + Clone {
|
||||
era_duration: u64,
|
||||
) -> (N, N)
|
||||
where
|
||||
N: AtLeast32BitUnsigned + Clone,
|
||||
{
|
||||
// Milliseconds per year for the Julian year (365.25 days).
|
||||
const MILLISECONDS_PER_YEAR: u64 = 1000 * 3600 * 24 * 36525 / 100;
|
||||
|
||||
let portion = Perbill::from_rational(era_duration as u64, MILLISECONDS_PER_YEAR);
|
||||
let payout = portion * yearly_inflation.calculate_for_fraction_times_denominator(
|
||||
npos_token_staked,
|
||||
total_tokens.clone(),
|
||||
);
|
||||
let payout = portion *
|
||||
yearly_inflation
|
||||
.calculate_for_fraction_times_denominator(npos_token_staked, total_tokens.clone());
|
||||
let maximum = portion * (yearly_inflation.maximum * total_tokens);
|
||||
(payout, maximum)
|
||||
}
|
||||
@@ -70,7 +72,7 @@ mod test {
|
||||
// not 10_000 due to rounding error.
|
||||
assert_eq!(super::compute_total_payout(&I_NPOS, 0, 100_000u64, YEAR).1, 9_993);
|
||||
|
||||
//super::I_NPOS.calculate_for_fraction_times_denominator(25, 100)
|
||||
// super::I_NPOS.calculate_for_fraction_times_denominator(25, 100)
|
||||
assert_eq!(super::compute_total_payout(&I_NPOS, 0, 100_000u64, YEAR).0, 2_498);
|
||||
assert_eq!(super::compute_total_payout(&I_NPOS, 5_000, 100_000u64, YEAR).0, 3_248);
|
||||
assert_eq!(super::compute_total_payout(&I_NPOS, 25_000, 100_000u64, YEAR).0, 6_246);
|
||||
@@ -98,7 +100,8 @@ mod test {
|
||||
2_500_000_000_000_000_000_000_000_000u128,
|
||||
5_000_000_000_000_000_000_000_000_000u128,
|
||||
HOUR
|
||||
).0,
|
||||
)
|
||||
.0,
|
||||
57_038_500_000_000_000_000_000
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user