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
+11 -11
View File
@@ -24,7 +24,7 @@
use sp_runtime::RuntimeDebug;
use codec::{Encode, Decode};
use codec::{Decode, Encode};
use sp_std::vec::Vec;
#[cfg(test)]
@@ -34,9 +34,9 @@ pub use pallet::*;
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use super::*;
#[pallet::config]
pub trait Config: frame_system::Config {
@@ -65,9 +65,10 @@ pub mod pallet {
/// The example utilizes parallel execution by checking half of the
/// signatures in spawned task.
#[pallet::weight(0)]
pub fn enlist_participants(origin: OriginFor<T>, participants: Vec<EnlistedParticipant>)
-> DispatchResultWithPostInfo
{
pub fn enlist_participants(
origin: OriginFor<T>,
participants: Vec<EnlistedParticipant>,
) -> DispatchResultWithPostInfo {
let _ = ensure_signed(origin)?;
if validate_participants_parallel(&<CurrentEventId<T>>::get(), &participants[..]) {
@@ -103,21 +104,20 @@ pub struct EnlistedParticipant {
impl EnlistedParticipant {
fn verify(&self, event_id: &[u8]) -> bool {
use sp_core::Public;
use std::convert::TryFrom;
use sp_runtime::traits::Verify;
use std::convert::TryFrom;
match sp_core::sr25519::Signature::try_from(&self.signature[..]) {
Ok(signature) => {
let public = sp_core::sr25519::Public::from_slice(self.account.as_ref());
signature.verify(event_id, &public)
}
_ => false
},
_ => false,
}
}
}
fn validate_participants_parallel(event_id: &[u8], participants: &[EnlistedParticipant]) -> bool {
fn spawn_verify(data: Vec<u8>) -> Vec<u8> {
let stream = &mut &data[..];
let event_id = Vec::<u8>::decode(stream).expect("Failed to decode");
@@ -138,10 +138,10 @@ fn validate_participants_parallel(event_id: &[u8], participants: &[EnlistedParti
let handle = sp_tasks::spawn(spawn_verify, async_payload);
let mut result = true;
for participant in &participants[participants.len()/2+1..] {
for participant in &participants[participants.len() / 2 + 1..] {
if !participant.verify(event_id) {
result = false;
break;
break
}
}