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
+26 -33
View File
@@ -21,16 +21,19 @@
#![deny(unused_crate_dependencies)]
use sp_runtime::traits::{Block as BlockT, NumberFor};
use sp_blockchain::HeaderBackend;
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, NumberFor},
};
use std::sync::Arc;
use sp_runtime::generic::BlockId;
use jsonrpc_derive::rpc;
type SharedAuthoritySet<TBl> =
sc_finality_grandpa::SharedAuthoritySet<<TBl as BlockT>::Hash, NumberFor<TBl>>;
type SharedEpochChanges<TBl> = sc_consensus_epochs::SharedEpochChanges<TBl, sc_consensus_babe::Epoch>;
type SharedEpochChanges<TBl> =
sc_consensus_epochs::SharedEpochChanges<TBl, sc_consensus_babe::Epoch>;
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
@@ -51,11 +54,7 @@ impl<Block: BlockT> From<Error<Block>> for jsonrpc_core::Error {
Error::JsonRpc(s) => s,
_ => error.to_string(),
};
jsonrpc_core::Error {
message,
code: jsonrpc_core::ErrorCode::ServerError(1),
data: None,
}
jsonrpc_core::Error { message, code: jsonrpc_core::ErrorCode::ServerError(1), data: None }
}
}
@@ -64,8 +63,7 @@ impl<Block: BlockT> From<Error<Block>> for jsonrpc_core::Error {
pub trait SyncStateRpcApi {
/// Returns the json-serialized chainspec running the node, with a sync state.
#[rpc(name = "sync_state_genSyncSpec", returns = "jsonrpc_core::Value")]
fn system_gen_sync_spec(&self, raw: bool)
-> jsonrpc_core::Result<jsonrpc_core::Value>;
fn system_gen_sync_spec(&self, raw: bool) -> jsonrpc_core::Result<jsonrpc_core::Value>;
}
/// The handler for sync state RPC calls.
@@ -78,9 +76,9 @@ pub struct SyncStateRpcHandler<TBl: BlockT, TCl> {
}
impl<TBl, TCl> SyncStateRpcHandler<TBl, TCl>
where
TBl: BlockT,
TCl: HeaderBackend<TBl> + sc_client_api::AuxStore + 'static,
where
TBl: BlockT,
TCl: HeaderBackend<TBl> + sc_client_api::AuxStore + 'static,
{
/// Create a new handler.
pub fn new(
@@ -90,21 +88,19 @@ impl<TBl, TCl> SyncStateRpcHandler<TBl, TCl>
shared_epoch_changes: SharedEpochChanges<TBl>,
deny_unsafe: sc_rpc_api::DenyUnsafe,
) -> Self {
Self {
chain_spec, client, shared_authority_set, shared_epoch_changes, deny_unsafe,
}
Self { chain_spec, client, shared_authority_set, shared_epoch_changes, deny_unsafe }
}
fn build_sync_state(&self) -> Result<sc_chain_spec::LightSyncState<TBl>, Error<TBl>> {
let finalized_hash = self.client.info().finalized_hash;
let finalized_header = self.client.header(BlockId::Hash(finalized_hash))?
let finalized_header = self
.client
.header(BlockId::Hash(finalized_hash))?
.ok_or_else(|| sp_blockchain::Error::MissingHeader(finalized_hash.to_string()))?;
let finalized_block_weight = sc_consensus_babe::aux_schema::load_block_weight(
&*self.client,
finalized_hash,
)?
.ok_or_else(|| Error::LoadingBlockWeightFailed(finalized_hash))?;
let finalized_block_weight =
sc_consensus_babe::aux_schema::load_block_weight(&*self.client, finalized_hash)?
.ok_or_else(|| Error::LoadingBlockWeightFailed(finalized_hash))?;
Ok(sc_chain_spec::LightSyncState {
finalized_block_header: finalized_header,
@@ -116,26 +112,23 @@ impl<TBl, TCl> SyncStateRpcHandler<TBl, TCl>
}
impl<TBl, TCl> SyncStateRpcApi for SyncStateRpcHandler<TBl, TCl>
where
TBl: BlockT,
TCl: HeaderBackend<TBl> + sc_client_api::AuxStore + 'static,
where
TBl: BlockT,
TCl: HeaderBackend<TBl> + sc_client_api::AuxStore + 'static,
{
fn system_gen_sync_spec(&self, raw: bool)
-> jsonrpc_core::Result<jsonrpc_core::Value>
{
fn system_gen_sync_spec(&self, raw: bool) -> jsonrpc_core::Result<jsonrpc_core::Value> {
if let Err(err) = self.deny_unsafe.check_if_safe() {
return Err(err.into());
return Err(err.into())
}
let mut chain_spec = self.chain_spec.cloned_box();
let sync_state = self.build_sync_state()
.map_err(map_error::<TBl,Error<TBl>>)?;
let sync_state = self.build_sync_state().map_err(map_error::<TBl, Error<TBl>>)?;
chain_spec.set_light_sync_state(sync_state.to_serializable());
let string = chain_spec.as_json(raw).map_err(map_error::<TBl,_>)?;
let string = chain_spec.as_json(raw).map_err(map_error::<TBl, _>)?;
serde_json::from_str(&string).map_err(|err| map_error::<TBl,_>(err))
serde_json::from_str(&string).map_err(|err| map_error::<TBl, _>(err))
}
}