Skip to content

Commit

Permalink
fmt fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
smohan-dw committed Jun 17, 2024
1 parent 431fd34 commit 33232d9
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 58 deletions.
10 changes: 4 additions & 6 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,11 @@ impl SubstrateCli for Cli {
#[cfg(feature = "weave-native")]
"weave-dev" => Box::new(chain_spec::weave_development_config()?),
#[cfg(not(feature = "braid-native"))]
name if name.starts_with("braid-") && !name.ends_with(".json") => {
Err(format!("`{}` only supported with `braid-native` feature enabled.", name))?
},
name if name.starts_with("braid-") && !name.ends_with(".json") =>
Err(format!("`{}` only supported with `braid-native` feature enabled.", name))?,
#[cfg(not(feature = "loom-native"))]
name if name.starts_with("loom-") && !name.ends_with(".json") => {
Err(format!("`{}` only supported with `loom-native` feature enabled.", name))?
},
name if name.starts_with("loom-") && !name.ends_with(".json") =>
Err(format!("`{}` only supported with `loom-native` feature enabled.", name))?,
// "weave" => Box::new(chain_spec::weave_config()?),
path => {
let path = std::path::PathBuf::from(path);
Expand Down
6 changes: 3 additions & 3 deletions node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,9 @@ pub fn new_full_base<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(
) -> Result<NewFullBase, ServiceError> {
let role = config.role.clone();
let force_authoring = config.force_authoring;
let backoff_authoring_blocks = if config.chain_spec.is_braid()
|| config.chain_spec.is_loom()
|| config.chain_spec.is_weave()
let backoff_authoring_blocks = if config.chain_spec.is_braid() ||
config.chain_spec.is_loom() ||
config.chain_spec.is_weave()
{
// the block authoring backoff is disabled on production networks
None
Expand Down
10 changes: 4 additions & 6 deletions node/testing/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,11 @@ impl<'a> Iterator for BlockContentIterator<'a> {
signed_extra(0, cord_loom_runtime::ExistentialDeposit::get() + 1),
)),
function: match self.content.block_type {
BlockType::RandomTransfersKeepAlive => {
BlockType::RandomTransfersKeepAlive =>
RuntimeCall::Balances(BalancesCall::transfer_keep_alive {
dest: sp_runtime::MultiAddress::Id(receiver),
value: cord_loom_runtime::ExistentialDeposit::get() + 1,
})
},
}),
BlockType::RandomTransfersReaping => {
RuntimeCall::Balances(BalancesCall::transfer_allow_death {
dest: sp_runtime::MultiAddress::Id(receiver),
Expand All @@ -314,9 +313,8 @@ impl<'a> Iterator for BlockContentIterator<'a> {
value: 100 * UNITS - (cord_loom_runtime::ExistentialDeposit::get() - 1),
})
},
BlockType::Noop => {
RuntimeCall::System(SystemCall::remark { remark: Vec::new() })
},
BlockType::Noop =>
RuntimeCall::System(SystemCall::remark { remark: Vec::new() }),
},
},
self.runtime_version.spec_version,
Expand Down
27 changes: 14 additions & 13 deletions pallets/chain-space/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,16 +806,16 @@ pub mod pallet {
ensure!(
(parent_details.txn_capacity >=
(parent_details.txn_count +
parent_details.txn_reserve +
new_txn_capacity - space_details.txn_capacity)),
parent_details.txn_reserve + new_txn_capacity -
space_details.txn_capacity)),
Error::<T>::CapacityLessThanUsage
);

<Spaces<T>>::insert(
&space_details.parent.clone(),
SpaceDetailsOf::<T> {
txn_reserve: parent_details.txn_reserve - space_details.txn_capacity
+ new_txn_capacity,
txn_reserve: parent_details.txn_reserve - space_details.txn_capacity +
new_txn_capacity,
..parent_details.clone()
},
);
Expand Down Expand Up @@ -1011,7 +1011,8 @@ pub mod pallet {
// Check if the network is permissioned
let is_permissioned = T::NetworkPermission::is_permissioned();

// Ensure count is provided for permissioned networks, else set default for permissionless
// Ensure count is provided for permissioned networks, else set default for
// permissionless
let count = match count {
Some(value) => value,
None if is_permissioned => return Err(Error::<T>::CapacityValueMissing.into()),
Expand All @@ -1020,9 +1021,9 @@ pub mod pallet {

// Ensure the new capacity is greater than the current usage
ensure!(
count
<= (space_details.txn_capacity
- (space_details.txn_count + space_details.txn_reserve)),
count <=
(space_details.txn_capacity -
(space_details.txn_count + space_details.txn_reserve)),
Error::<T>::CapacityLimitExceeded
);

Expand Down Expand Up @@ -1154,17 +1155,17 @@ pub mod pallet {

// Ensure the new capacity is greater than the current usage
ensure!(
(parent_details.txn_capacity
>= (parent_details.txn_count + parent_details.txn_reserve + new_txn_capacity
- space_details.txn_capacity)),
(parent_details.txn_capacity >=
(parent_details.txn_count + parent_details.txn_reserve + new_txn_capacity -
space_details.txn_capacity)),
Error::<T>::CapacityLessThanUsage
);

<Spaces<T>>::insert(
&space_details.parent.clone(),
SpaceDetailsOf::<T> {
txn_reserve: parent_details.txn_reserve - space_details.txn_capacity
+ new_txn_capacity,
txn_reserve: parent_details.txn_reserve - space_details.txn_capacity +
new_txn_capacity,
..parent_details.clone()
},
);
Expand Down
4 changes: 2 additions & 2 deletions pallets/identity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,8 +1137,8 @@ impl<T: Config> Pallet<T> {
(
valid &&
(cur_char.is_ascii_lowercase() ||
cur_char.is_ascii_digit() ||
cur_char == b'.') && !(last_char == Some(b'.') && cur_char == b'.'),
cur_char.is_ascii_digit() || cur_char == b'.') &&
!(last_char == Some(b'.') && cur_char == b'.'),
Some(cur_char),
)
})
Expand Down
16 changes: 8 additions & 8 deletions pallets/network-score/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,10 @@ pub mod pallet {
.map_err(<pallet_chain_space::Error<T>>::from)?;

ensure!(
entry.total_encoded_rating > 0
&& entry.count_of_txn > 0
&& entry.total_encoded_rating
<= entry.count_of_txn * T::MaxRatingValue::get() as u64,
entry.total_encoded_rating > 0 &&
entry.count_of_txn > 0 &&
entry.total_encoded_rating <=
entry.count_of_txn * T::MaxRatingValue::get() as u64,
Error::<T>::InvalidRatingValue
);

Expand Down Expand Up @@ -634,10 +634,10 @@ pub mod pallet {
.map_err(<pallet_chain_space::Error<T>>::from)?;

ensure!(
entry.total_encoded_rating > 0
&& entry.count_of_txn > 0
&& entry.total_encoded_rating
<= entry.count_of_txn * T::MaxRatingValue::get() as u64,
entry.total_encoded_rating > 0 &&
entry.count_of_txn > 0 &&
entry.total_encoded_rating <=
entry.count_of_txn * T::MaxRatingValue::get() as u64,
Error::<T>::InvalidRatingValue
);

Expand Down
6 changes: 4 additions & 2 deletions runtimes/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
#![cfg_attr(not(feature = "std"), no_std)]

use cord_primitives::{AccountId, Balance, BlockNumber};
use frame_support::parameter_types;
use frame_support::traits::{Currency, OnUnbalanced};
use frame_support::{
parameter_types,
traits::{Currency, OnUnbalanced},
};

use frame_system::limits;
use sp_runtime::{FixedPointNumber, Perbill, Perquintill};
Expand Down
5 changes: 2 additions & 3 deletions test-utils/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,8 @@ pub async fn block_hash(block_number: u64, url: &str) -> Result<Hash, String> {
.map_err(|_| "Couldn't get block hash".to_string())?;

match result {
ListOrValue::Value(maybe_block_hash) if maybe_block_hash.is_some() => {
Ok(maybe_block_hash.unwrap())
},
ListOrValue::Value(maybe_block_hash) if maybe_block_hash.is_some() =>
Ok(maybe_block_hash.unwrap()),
_ => Err("Couldn't get block hash".to_string()),
}
}
Expand Down
5 changes: 2 additions & 3 deletions test-utils/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,8 @@ impl sp_runtime::traits::SignedExtension for CheckSubstrateCall {
) -> TransactionValidity {
log::trace!(target: LOG_TARGET, "validate");
match call {
RuntimeCall::CordTest(ref cord_test_call) => {
cord_test_pallet::validate_runtime_call(cord_test_call)
},
RuntimeCall::CordTest(ref cord_test_call) =>
cord_test_pallet::validate_runtime_call(cord_test_call),
_ => Ok(Default::default()),
}
}
Expand Down
19 changes: 7 additions & 12 deletions test-utils/runtime/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,10 @@ impl ChainApi for TestApi {
))));
}
},
Ok(None) => {
Ok(None) =>
return ready(Ok(Err(TransactionValidityError::Invalid(
InvalidTransaction::Custom(2),
))))
},
)))),
Err(e) => return ready(Err(e)),
}

Expand All @@ -318,9 +317,7 @@ impl ChainApi for TestApi {
};

if self.chain.read().invalid_hashes.contains(&self.hash_and_length(&uxt).0) {
return ready(Ok(Err(TransactionValidityError::Invalid(InvalidTransaction::Custom(
0,
)))));
return ready(Ok(Err(TransactionValidityError::Invalid(InvalidTransaction::Custom(0)))));
}

let priority = self.chain.read().priorities.get(&self.hash_and_length(&uxt).0).cloned();
Expand All @@ -342,9 +339,8 @@ impl ChainApi for TestApi {
at: &BlockId<Self::Block>,
) -> Result<Option<NumberFor<Self::Block>>, Error> {
Ok(match at {
generic::BlockId::Hash(x) => {
self.chain.read().block_by_hash.get(x).map(|b| *b.header.number())
},
generic::BlockId::Hash(x) =>
self.chain.read().block_by_hash.get(x).map(|b| *b.header.number()),
generic::BlockId::Number(num) => Some(*num),
})
}
Expand All @@ -355,11 +351,10 @@ impl ChainApi for TestApi {
) -> Result<Option<<Self::Block as BlockT>::Hash>, Error> {
Ok(match at {
generic::BlockId::Hash(x) => Some(*x),
generic::BlockId::Number(num) => {
generic::BlockId::Number(num) =>
self.chain.read().block_by_number.get(num).and_then(|blocks| {
blocks.iter().find(|b| b.1.is_best()).map(|b| b.0.header().hash())
})
},
}),
})
}

Expand Down

0 comments on commit 33232d9

Please sign in to comment.