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:
Bastian Köcher
2021-07-21 16:32:32 +02:00
committed by GitHub
parent d451c38c1c
commit 7b56ab15b4
1010 changed files with 53339 additions and 51208 deletions
+20 -20
View File
@@ -19,22 +19,27 @@
#![cfg(test)]
use std::cell::RefCell;
use crate as offences;
use crate::Config;
use codec::Encode;
use sp_runtime::Perbill;
use sp_staking::{
SessionIndex,
offence::{self, Kind, OffenceDetails},
};
use sp_runtime::testing::Header;
use sp_runtime::traits::{IdentityLookup, BlakeTwo256};
use sp_core::H256;
use frame_support::{
parameter_types,
weights::{Weight, constants::{WEIGHT_PER_SECOND, RocksDbWeight}},
weights::{
constants::{RocksDbWeight, WEIGHT_PER_SECOND},
Weight,
},
};
use crate as offences;
use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
Perbill,
};
use sp_staking::{
offence::{self, Kind, OffenceDetails},
SessionIndex,
};
use std::cell::RefCell;
pub struct OnOffenceHandler;
@@ -43,8 +48,8 @@ thread_local! {
pub static OFFENCE_WEIGHT: RefCell<Weight> = RefCell::new(Default::default());
}
impl<Reporter, Offender>
offence::OnOffenceHandler<Reporter, Offender, Weight> for OnOffenceHandler
impl<Reporter, Offender> offence::OnOffenceHandler<Reporter, Offender, Weight>
for OnOffenceHandler
{
fn on_offence(
_offenders: &[OffenceDetails<Reporter, Offender>],
@@ -60,9 +65,7 @@ impl<Reporter, Offender>
}
pub fn with_on_offence_fractions<R, F: FnOnce(&mut Vec<Perbill>) -> R>(f: F) -> R {
ON_OFFENCE_PERBILL.with(|fractions| {
f(&mut *fractions.borrow_mut())
})
ON_OFFENCE_PERBILL.with(|fractions| f(&mut *fractions.borrow_mut()))
}
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
@@ -163,10 +166,7 @@ impl<T: Clone> offence::Offence<T> for Offence<T> {
1
}
fn slash_fraction(
offenders_count: u32,
validator_set_count: u32,
) -> Perbill {
fn slash_fraction(offenders_count: u32, validator_set_count: u32) -> Perbill {
Perbill::from_percent(5 + offenders_count * 100 / validator_set_count)
}
}