Skip to content

Commit

Permalink
update rustfmt.toml (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
frank0528 authored Oct 10, 2024
1 parent b9d6a4f commit 9745533
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 50 deletions.
10 changes: 6 additions & 4 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ impl SubstrateCli for Cli {
"local" => Box::new(chain_spec::local_testnet_config()),
"fir" | "flaming-fir" => Box::new(chain_spec::flaming_fir_config()?),
"staging" => Box::new(chain_spec::staging_testnet_config()),
path =>
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
path => {
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?)
},
})
}

Expand Down Expand Up @@ -175,8 +176,9 @@ pub fn run() -> sc_cli::Result<()> {

cmd.run(client, inherent_benchmark_data()?, Vec::new(), &ext_factory)
},
BenchmarkCmd::Machine(cmd) =>
cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()),
BenchmarkCmd::Machine(cmd) => {
cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())
},
}
})
},
Expand Down
10 changes: 6 additions & 4 deletions node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,17 @@ where
path: frontier_database_dir(config, "db"),
cache_size: 0,
},
DatabaseSource::ParityDb { .. } =>
DatabaseSource::ParityDb { path: frontier_database_dir(config, "paritydb") },
DatabaseSource::ParityDb { .. } => {
DatabaseSource::ParityDb { path: frontier_database_dir(config, "paritydb") }
},
DatabaseSource::Auto { .. } => DatabaseSource::Auto {
rocksdb_path: frontier_database_dir(config, "db"),
paritydb_path: frontier_database_dir(config, "paritydb"),
cache_size: 0,
},
_ =>
return Err("Supported db sources: `rocksdb` | `paritydb` | `auto`".to_string()),
_ => {
return Err("Supported db sources: `rocksdb` | `paritydb` | `auto`".to_string())
},
},
},
)?);
Expand Down
5 changes: 3 additions & 2 deletions pallets/dbc-price-ocw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@ pub mod pallet {
};

match call {
Call::submit_price_unsigned { price: _ } =>
valid_tx(b"submit_price_unsigned".to_vec()),
Call::submit_price_unsigned { price: _ } => {
valid_tx(b"submit_price_unsigned".to_vec())
},
_ => InvalidTransaction::Call.into(),
}
}
Expand Down
10 changes: 6 additions & 4 deletions pallets/maintain-committee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,14 @@ pub mod pallet {

let result = <online_profile::Pallet<T>>::machines_info(&rent_info.machine_id);
match result {
Some(machine_info) =>
Some(machine_info) => {
if machine_info.machine_status == MachineStatus::Rented {
<online_profile::Pallet<T>>::add_offline_machine_to_renters(
rent_info.machine_id,
machine_info.renters,
);
},
}
},
None => {},
}

Expand Down Expand Up @@ -752,15 +753,16 @@ pub mod pallet {

let result = <online_profile::Pallet<T>>::machines_info(&rent_info.machine_id);
match result {
Some(machine_info) =>
Some(machine_info) => {
if machine_info.machine_status == MachineStatus::Rented {
let renters =
<rent_dlc_machine::Pallet<T>>::get_renters(&rent_info.machine_id);
<online_profile::Pallet<T>>::add_offline_machine_to_renters(
rent_info.machine_id,
renters,
);
},
}
},
None => {},
}
}
Expand Down
10 changes: 6 additions & 4 deletions pallets/maintain-committee/src/types/report_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ pub fn into_op_err<BlockNumber>(
) -> OPSlashReason<BlockNumber> {
match fault_type {
MachineFaultType::RentedInaccessible(..) => OPSlashReason::RentedInaccessible(report_time),
MachineFaultType::RentedHardwareMalfunction(..) =>
OPSlashReason::RentedHardwareMalfunction(report_time),
MachineFaultType::RentedHardwareCounterfeit(..) =>
OPSlashReason::RentedHardwareCounterfeit(report_time),
MachineFaultType::RentedHardwareMalfunction(..) => {
OPSlashReason::RentedHardwareMalfunction(report_time)
},
MachineFaultType::RentedHardwareCounterfeit(..) => {
OPSlashReason::RentedHardwareCounterfeit(report_time)
},
MachineFaultType::OnlineRentFailed(..) => OPSlashReason::OnlineRentFailed(report_time),
}
}
15 changes: 9 additions & 6 deletions pallets/nfts/src/features/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,19 +363,22 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
) -> Result<bool, DispatchError> {
let mut result = false;
match namespace {
AttributeNamespace::CollectionOwner =>
result = Self::has_role(&collection, &origin, CollectionRole::Admin),
AttributeNamespace::ItemOwner =>
AttributeNamespace::CollectionOwner => {
result = Self::has_role(&collection, &origin, CollectionRole::Admin)
},
AttributeNamespace::ItemOwner => {
if let Some(item) = maybe_item {
let item_details =
Item::<T, I>::get(&collection, &item).ok_or(Error::<T, I>::UnknownItem)?;
result = origin == &item_details.owner
},
AttributeNamespace::Account(account_id) =>
}
},
AttributeNamespace::Account(account_id) => {
if let Some(item) = maybe_item {
let approvals = ItemAttributesApprovalsOf::<T, I>::get(&collection, &item);
result = account_id == origin && approvals.contains(&origin)
},
}
},
_ => (),
};
Ok(result)
Expand Down
4 changes: 3 additions & 1 deletion pallets/nfts/src/impl_nonfungibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ impl<T: Config<I>, I: 'static> Inspect<<T as SystemConfig>::AccountId> for Palle
(Some(cc), Some(ic))
if cc.is_setting_enabled(CollectionSetting::TransferableItems) &&
ic.is_setting_enabled(ItemSetting::Transferable) =>
true,
{
true
},
_ => false,
}
}
Expand Down
5 changes: 3 additions & 2 deletions pallets/nfts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1371,8 +1371,9 @@ pub mod pallet {
) -> DispatchResult {
let origin = ensure_signed(origin)?;
let depositor = match namespace {
AttributeNamespace::CollectionOwner =>
Self::collection_owner(collection).ok_or(Error::<T, I>::UnknownCollection)?,
AttributeNamespace::CollectionOwner => {
Self::collection_owner(collection).ok_or(Error::<T, I>::UnknownCollection)?
},
_ => origin.clone(),
};
Self::do_set_attribute(origin, collection, maybe_item, namespace, key, value, depositor)
Expand Down
5 changes: 3 additions & 2 deletions pallets/online-profile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,8 +1076,9 @@ pub mod pallet {
let machine_info = Self::machines_info(&machine_id).ok_or(Error::<T>::Unknown)?;

let offline_time = match machine_info.machine_status.clone() {
MachineStatus::StakerReportOffline(_offline_time, _) =>
return Err(Error::<T>::MachineStatusNotAllowed.into()),
MachineStatus::StakerReportOffline(_offline_time, _) => {
return Err(Error::<T>::MachineStatusNotAllowed.into())
},
MachineStatus::ReporterReportOffline(slash_reason, ..) => match slash_reason {
OPSlashReason::RentedInaccessible(report_time) |
OPSlashReason::RentedHardwareMalfunction(report_time) |
Expand Down
15 changes: 9 additions & 6 deletions pallets/staking/src/pallet/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,10 @@ impl<T: Config> Pallet<T> {
.retain(|&x| x >= current_era.saturating_sub(history_depth));

match ledger.claimed_rewards.binary_search(&era) {
Ok(_) =>
Ok(_) => {
return Err(Error::<T>::AlreadyClaimed
.with_weight(T::WeightInfo::payout_stakers_alive_staked(0))),
.with_weight(T::WeightInfo::payout_stakers_alive_staked(0)))
},
Err(pos) => ledger
.claimed_rewards
.try_insert(pos, era)
Expand Down Expand Up @@ -306,8 +307,9 @@ impl<T: Config> Pallet<T> {
Self::update_ledger(&controller, &l);
r
}),
RewardDestination::Account(dest_account) =>
Some(T::Currency::deposit_creating(&dest_account, amount)),
RewardDestination::Account(dest_account) => {
Some(T::Currency::deposit_creating(&dest_account, amount))
},
RewardDestination::None => None,
}
}
Expand Down Expand Up @@ -1908,10 +1910,11 @@ impl<T: Config> Pallet<T> {
match len {
0 => { /* not supporting this validator at all. */ },
1 => sum += individual[0].value,
_ =>
_ => {
return Err(
"nominator cannot back a validator more than once.".into()
),
)
},
};
Ok(())
})
Expand Down
5 changes: 3 additions & 2 deletions pallets/support/src/report/report_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,13 @@ where
}

self.report_status = match self.machine_fault_type {
MachineFaultType::RentedInaccessible(..) =>
MachineFaultType::RentedInaccessible(..) => {
if self.booked_committee.len() == 3 {
ReportStatus::Verifying
} else {
ReportStatus::WaitingBook
},
}
},
_ => {
// 仅在不是RentedInaccessible时进行记录,因为这些情况只能一次有一个验证委员会
self.verifying_committee = Some(committee);
Expand Down
10 changes: 6 additions & 4 deletions pallets/terminating-rental/src/types/custom_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ pub fn into_op_err<BlockNumber>(
) -> OPSlashReason<BlockNumber> {
match fault_type {
MachineFaultType::RentedInaccessible(..) => OPSlashReason::RentedInaccessible(report_time),
MachineFaultType::RentedHardwareMalfunction(..) =>
OPSlashReason::RentedHardwareMalfunction(report_time),
MachineFaultType::RentedHardwareCounterfeit(..) =>
OPSlashReason::RentedHardwareCounterfeit(report_time),
MachineFaultType::RentedHardwareMalfunction(..) => {
OPSlashReason::RentedHardwareMalfunction(report_time)
},
MachineFaultType::RentedHardwareCounterfeit(..) => {
OPSlashReason::RentedHardwareCounterfeit(report_time)
},
MachineFaultType::OnlineRentFailed(..) => OPSlashReason::OnlineRentFailed(report_time),
}
}
20 changes: 12 additions & 8 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,9 @@ impl StaticLookup for EvmAddressMapping {

fn lookup(a: Self::Source) -> Result<Self::Target, LookupError> {
match a {
MultiAddress::Address20(i) =>
Ok(HashedAddressMapping::<BlakeTwo256>::into_account_id(H160::from(&i)).into()),
MultiAddress::Address20(i) => {
Ok(HashedAddressMapping::<BlakeTwo256>::into_account_id(H160::from(&i)).into())
},
_ => Err(LookupError),
}
}
Expand Down Expand Up @@ -1793,8 +1794,9 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall {
len: usize,
) -> Option<TransactionValidity> {
match self {
RuntimeCall::Ethereum(call) =>
call.validate_self_contained(signed_info, dispatch_info, len),
RuntimeCall::Ethereum(call) => {
call.validate_self_contained(signed_info, dispatch_info, len)
},
_ => None,
}
}
Expand All @@ -1806,8 +1808,9 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall {
len: usize,
) -> Option<Result<(), TransactionValidityError>> {
match self {
RuntimeCall::Ethereum(call) =>
call.pre_dispatch_self_contained(info, dispatch_info, len),
RuntimeCall::Ethereum(call) => {
call.pre_dispatch_self_contained(info, dispatch_info, len)
},
_ => None,
}
}
Expand All @@ -1817,10 +1820,11 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall {
info: Self::SignedInfo,
) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {
match self {
call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) =>
call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => {
Some(call.dispatch(RuntimeOrigin::from(
pallet_ethereum::RawOrigin::EthereumTransaction(info),
))),
)))
},
_ => None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ newline_style = "Unix"
# Misc
chain_width = 80
binop_separator = "Back"
match_arm_blocks = false
match_arm_blocks = true
match_arm_leading_pipes = "Preserve"
match_block_trailing_comma = true
use_field_init_shorthand = true
Expand Down

0 comments on commit 9745533

Please sign in to comment.