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
+35 -32
View File
@@ -21,24 +21,25 @@
#[cfg(test)]
mod tests;
use futures::{future::BoxFuture, FutureExt, TryFutureExt};
use futures::{channel::oneshot, compat::Compat};
use futures::{channel::oneshot, compat::Compat, future::BoxFuture, FutureExt, TryFutureExt};
use sc_rpc_api::{DenyUnsafe, Receiver};
use sc_tracing::logging;
use sp_utils::mpsc::TracingUnboundedSender;
use sp_runtime::traits::{self, Header as HeaderT};
use sp_utils::mpsc::TracingUnboundedSender;
use self::error::Result;
pub use self::{
gen_client::Client as SystemClient,
helpers::{Health, NodeRole, PeerInfo, SyncState, SystemInfo},
};
pub use sc_rpc_api::system::*;
pub use self::helpers::{SystemInfo, Health, PeerInfo, NodeRole, SyncState};
pub use self::gen_client::Client as SystemClient;
/// Early exit for RPCs that require `--rpc-methods=Unsafe` to be enabled
macro_rules! bail_if_unsafe {
($value: expr) => {
if let Err(err) = $value.check_if_safe() {
return async move { Err(err.into()) }.boxed().compat();
return async move { Err(err.into()) }.boxed().compat()
}
};
}
@@ -85,11 +86,7 @@ impl<B: traits::Block> System<B> {
send_back: TracingUnboundedSender<Request<B>>,
deny_unsafe: DenyUnsafe,
) -> Self {
System {
info,
send_back,
deny_unsafe,
}
System { info, send_back, deny_unsafe }
}
}
@@ -132,35 +129,36 @@ impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for Sy
Receiver(Compat::new(rx))
}
fn system_peers(&self)
-> Compat<BoxFuture<'static, rpc::Result<Vec<PeerInfo<B::Hash, <B::Header as HeaderT>::Number>>>>>
{
fn system_peers(
&self,
) -> Compat<
BoxFuture<'static, rpc::Result<Vec<PeerInfo<B::Hash, <B::Header as HeaderT>::Number>>>>,
> {
bail_if_unsafe!(self.deny_unsafe);
let (tx, rx) = oneshot::channel();
let _ = self.send_back.unbounded_send(Request::Peers(tx));
async move {
rx.await.map_err(|_| rpc::Error::internal_error())
}.boxed().compat()
async move { rx.await.map_err(|_| rpc::Error::internal_error()) }
.boxed()
.compat()
}
fn system_network_state(&self)
-> Compat<BoxFuture<'static, rpc::Result<rpc::Value>>>
{
fn system_network_state(&self) -> Compat<BoxFuture<'static, rpc::Result<rpc::Value>>> {
bail_if_unsafe!(self.deny_unsafe);
let (tx, rx) = oneshot::channel();
let _ = self.send_back.unbounded_send(Request::NetworkState(tx));
async move {
rx.await.map_err(|_| rpc::Error::internal_error())
}.boxed().compat()
async move { rx.await.map_err(|_| rpc::Error::internal_error()) }
.boxed()
.compat()
}
fn system_add_reserved_peer(&self, peer: String)
-> Compat<BoxFuture<'static, std::result::Result<(), rpc::Error>>>
{
fn system_add_reserved_peer(
&self,
peer: String,
) -> Compat<BoxFuture<'static, std::result::Result<(), rpc::Error>>> {
bail_if_unsafe!(self.deny_unsafe);
let (tx, rx) = oneshot::channel();
@@ -171,12 +169,15 @@ impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for Sy
Ok(Err(e)) => Err(rpc::Error::from(e)),
Err(_) => Err(rpc::Error::internal_error()),
}
}.boxed().compat()
}
.boxed()
.compat()
}
fn system_remove_reserved_peer(&self, peer: String)
-> Compat<BoxFuture<'static, std::result::Result<(), rpc::Error>>>
{
fn system_remove_reserved_peer(
&self,
peer: String,
) -> Compat<BoxFuture<'static, std::result::Result<(), rpc::Error>>> {
bail_if_unsafe!(self.deny_unsafe);
let (tx, rx) = oneshot::channel();
@@ -187,7 +188,9 @@ impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for Sy
Ok(Err(e)) => Err(rpc::Error::from(e)),
Err(_) => Err(rpc::Error::internal_error()),
}
}.boxed().compat()
}
.boxed()
.compat()
}
fn system_reserved_peers(&self) -> Receiver<Vec<String>> {
@@ -214,7 +217,7 @@ impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for Sy
logging::reload_filter().map_err(|_e| rpc::Error::internal_error())
}
fn system_reset_log_filter(&self)-> std::result::Result<(), rpc::Error> {
fn system_reset_log_filter(&self) -> std::result::Result<(), rpc::Error> {
self.deny_unsafe.check_if_safe()?;
logging::reset_log_filter().map_err(|_e| rpc::Error::internal_error())
}