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
@@ -18,30 +18,26 @@
//! Longest chain implementation
use std::sync::Arc;
use std::marker::PhantomData;
use sc_client_api::backend;
use sp_consensus::{SelectChain, Error as ConsensusError};
use sp_blockchain::{Backend, HeaderBackend};
use sp_consensus::{Error as ConsensusError, SelectChain};
use sp_runtime::{
traits::{NumberFor, Block as BlockT},
generic::BlockId,
traits::{Block as BlockT, NumberFor},
};
use std::{marker::PhantomData, sync::Arc};
/// Implement Longest Chain Select implementation
/// where 'longest' is defined as the highest number of blocks
pub struct LongestChain<B, Block> {
backend: Arc<B>,
_phantom: PhantomData<Block>
_phantom: PhantomData<Block>,
}
impl<B, Block> Clone for LongestChain<B, Block> {
fn clone(&self) -> Self {
let backend = self.backend.clone();
LongestChain {
backend,
_phantom: Default::default()
}
LongestChain { backend, _phantom: Default::default() }
}
}
@@ -52,21 +48,22 @@ where
{
/// Instantiate a new LongestChain for Backend B
pub fn new(backend: Arc<B>) -> Self {
LongestChain {
backend,
_phantom: Default::default(),
}
LongestChain { backend, _phantom: Default::default() }
}
fn best_block_header(&self) -> sp_blockchain::Result<<Block as BlockT>::Header> {
let info = self.backend.blockchain().info();
let import_lock = self.backend.get_import_lock();
let best_hash = self.backend
let best_hash = self
.backend
.blockchain()
.best_containing(info.best_hash, None, import_lock)?
.unwrap_or(info.best_hash);
Ok(self.backend.blockchain().header(BlockId::Hash(best_hash))?
Ok(self
.backend
.blockchain()
.header(BlockId::Hash(best_hash))?
.expect("given block hash was fetched from block in db; qed"))
}
@@ -18,8 +18,8 @@
//! Provides a generic wrapper around shared data. See [`SharedData`] for more information.
use parking_lot::{Condvar, MappedMutexGuard, Mutex, MutexGuard};
use std::sync::Arc;
use parking_lot::{Mutex, MappedMutexGuard, Condvar, MutexGuard};
/// Created by [`SharedDataLocked::release_mutex`].
///
@@ -75,8 +75,7 @@ impl<'a, T> SharedDataLocked<'a, T> {
/// Release the mutex, but keep the shared data locked.
pub fn release_mutex(mut self) -> SharedDataLockedUpgradable<T> {
SharedDataLockedUpgradable {
shared_data: self.shared_data.take()
.expect("`shared_data` is only taken on drop; qed"),
shared_data: self.shared_data.take().expect("`shared_data` is only taken on drop; qed"),
}
}
}
@@ -132,7 +131,7 @@ struct SharedDataInner<T> {
/// # Example
///
/// ```
///# use sc_consensus::shared_data::SharedData;
/// # use sc_consensus::shared_data::SharedData;
///
/// let shared_data = SharedData::new(String::from("hello world"));
///
@@ -174,10 +173,7 @@ pub struct SharedData<T> {
impl<T> Clone for SharedData<T> {
fn clone(&self) -> Self {
Self {
inner: self.inner.clone(),
cond_var: self.cond_var.clone(),
}
Self { inner: self.inner.clone(), cond_var: self.cond_var.clone() }
}
}
@@ -228,10 +224,7 @@ impl<T> SharedData<T> {
debug_assert!(!guard.locked);
guard.locked = true;
SharedDataLocked {
inner: guard,
shared_data: Some(self.clone()),
}
SharedDataLocked { inner: guard, shared_data: Some(self.clone()) }
}
}