From 789f33e8db8c6e62b5867446c95528d8e47bf5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Fri, 18 Jun 2021 15:34:58 +0200 Subject: [PATCH] chore: cargo fmt --- cli/src/cli.rs | 8 +----- core/src/consensus.rs | 8 +----- core/src/replay_stage.rs | 19 ++---------- gossip/src/crds_gossip_push.rs | 8 +----- local-cluster/src/local_cluster.rs | 3 +- local-cluster/tests/local_cluster.rs | 5 +--- programs/exchange/src/exchange_processor.rs | 8 ++---- runtime/src/accounts_db.rs | 32 +++++---------------- runtime/src/bank.rs | 3 +- sdk/program/src/message.rs | 6 ++-- upload-perf/src/upload-perf.rs | 7 ++--- 11 files changed, 24 insertions(+), 83 deletions(-) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index f4f4772fde..2f6ddf0a1c 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -1889,13 +1889,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult { pubkey, output_file, use_lamports_unit, - } => process_show_account( - &rpc_client, - config, - pubkey, - output_file, - *use_lamports_unit, - ), + } => process_show_account(&rpc_client, config, pubkey, output_file, *use_lamports_unit), CliCommand::Transfer { amount, to, diff --git a/core/src/consensus.rs b/core/src/consensus.rs index 43d1c837ae..05d6597022 100644 --- a/core/src/consensus.rs +++ b/core/src/consensus.rs @@ -218,13 +218,7 @@ impl Tower { ) .clone(); - Self::new( - my_pubkey, - vote_account, - root, - &heaviest_bank, - ledger_path, - ) + Self::new(my_pubkey, vote_account, root, &heaviest_bank, ledger_path) } pub(crate) fn collect_vote_lockouts( diff --git a/core/src/replay_stage.rs b/core/src/replay_stage.rs index c3ff51f1b4..694e36c12f 100644 --- a/core/src/replay_stage.rs +++ b/core/src/replay_stage.rs @@ -754,12 +754,7 @@ impl ReplayStage { ) }; - Self::initialize_progress_and_fork_choice( - &root_bank, - frozen_banks, - my_pubkey, - vote_account, - ) + Self::initialize_progress_and_fork_choice(&root_bank, frozen_banks, my_pubkey, vote_account) } pub(crate) fn initialize_progress_and_fork_choice( @@ -777,14 +772,7 @@ impl ReplayStage { let prev_leader_slot = progress.get_bank_prev_leader_slot(bank); progress.insert( bank.slot(), - ForkProgress::new_from_bank( - bank, - my_pubkey, - vote_account, - prev_leader_slot, - 0, - 0, - ), + ForkProgress::new_from_bank(bank, my_pubkey, vote_account, prev_leader_slot, 0, 0), ); } let root = root_bank.slot(); @@ -3107,8 +3095,7 @@ mod tests { let mut entries = entry::create_ticks(bank.ticks_per_slot(), hashes_per_tick, blockhash); let last_entry_hash = entries.last().unwrap().hash; - let tx = - system_transaction::transfer(genesis_keypair, &keypair.pubkey(), 2, blockhash); + let tx = system_transaction::transfer(genesis_keypair, &keypair.pubkey(), 2, blockhash); let trailing_entry = entry::next_entry(&last_entry_hash, 1, vec![tx]); entries.push(trailing_entry); entries_to_test_shreds(entries, slot, slot.saturating_sub(1), true, 0) diff --git a/gossip/src/crds_gossip_push.rs b/gossip/src/crds_gossip_push.rs index 38319995d1..6e7319a747 100644 --- a/gossip/src/crds_gossip_push.rs +++ b/gossip/src/crds_gossip_push.rs @@ -275,13 +275,7 @@ impl CrdsGossipPush { let need = Self::compute_need(self.num_active, self.active_set.len(), ratio); let mut new_items = HashMap::new(); let (weights, peers): (Vec<_>, Vec<_>) = self - .push_options( - crds, - self_id, - self_shred_version, - stakes, - gossip_validators, - ) + .push_options(crds, self_id, self_shred_version, stakes, gossip_validators) .into_iter() .unzip(); if peers.is_empty() { diff --git a/local-cluster/src/local_cluster.rs b/local-cluster/src/local_cluster.rs index c842d5bfe1..db496e3e77 100644 --- a/local-cluster/src/local_cluster.rs +++ b/local-cluster/src/local_cluster.rs @@ -448,8 +448,7 @@ impl LocalCluster { let (blockhash, _fee_calculator, _last_valid_slot) = client .get_recent_blockhash_with_commitment(CommitmentConfig::processed()) .unwrap(); - let mut tx = - system_transaction::transfer(source_keypair, dest_pubkey, lamports, blockhash); + let mut tx = system_transaction::transfer(source_keypair, dest_pubkey, lamports, blockhash); info!( "executing transfer of {} from {} to {}", lamports, diff --git a/local-cluster/tests/local_cluster.rs b/local-cluster/tests/local_cluster.rs index 48389d06cd..fc89729c40 100644 --- a/local-cluster/tests/local_cluster.rs +++ b/local-cluster/tests/local_cluster.rs @@ -2844,10 +2844,7 @@ fn test_hard_fork_invalidates_tower() { thread.join().unwrap(); // new slots should be rooted after hard-fork cluster relaunch - cluster - .lock() - .unwrap() - .check_for_new_roots(16, "hard fork"); + cluster.lock().unwrap().check_for_new_roots(16, "hard fork"); } #[test] diff --git a/programs/exchange/src/exchange_processor.rs b/programs/exchange/src/exchange_processor.rs index e16a06773b..ab63cf7ec6 100644 --- a/programs/exchange/src/exchange_processor.rs +++ b/programs/exchange/src/exchange_processor.rs @@ -311,9 +311,8 @@ impl ExchangeProcessor { Self::is_account_unallocated(keyed_accounts[ORDER_INDEX].try_account_ref()?.data())?; - let mut account = Self::deserialize_account( - keyed_accounts[ACCOUNT_INDEX].try_account_ref_mut()?.data(), - )?; + let mut account = + Self::deserialize_account(keyed_accounts[ACCOUNT_INDEX].try_account_ref_mut()?.data())?; if &account.owner != keyed_accounts[OWNER_INDEX].unsigned_key() { error!("Signer does not own account"); @@ -367,8 +366,7 @@ impl ExchangeProcessor { return Err(InstructionError::InvalidArgument); } - let order = - Self::deserialize_order(keyed_accounts[ORDER_INDEX].try_account_ref()?.data())?; + let order = Self::deserialize_order(keyed_accounts[ORDER_INDEX].try_account_ref()?.data())?; if &order.owner != keyed_accounts[OWNER_INDEX].unsigned_key() { error!("Signer does not own order"); diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 58ff9879b2..03b4b5b33a 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -1495,11 +1495,8 @@ impl AccountsDb { .map(|pubkeys: &[Pubkey]| { let mut reclaims = Vec::new(); for pubkey in pubkeys { - self.accounts_index.clean_rooted_entries( - pubkey, - &mut reclaims, - max_clean_root, - ); + self.accounts_index + .clean_rooted_entries(pubkey, &mut reclaims, max_clean_root); } reclaims }); @@ -9517,10 +9514,7 @@ pub mod tests { let dummy_id1 = 22; let entry1 = Arc::new(AccountStorageEntry::new( - dummy_path, - dummy_slot, - dummy_id1, - dummy_size, + dummy_path, dummy_slot, dummy_id1, dummy_size, )); entry1.alive_bytes.store(8000, Ordering::Relaxed); @@ -9531,10 +9525,7 @@ pub mod tests { let dummy_id2 = 44; let entry2 = Arc::new(AccountStorageEntry::new( - dummy_path, - dummy_slot, - dummy_id2, - dummy_size, + dummy_path, dummy_slot, dummy_id2, dummy_size, )); entry2.alive_bytes.store(3000, Ordering::Relaxed); candidates @@ -9553,10 +9544,7 @@ pub mod tests { let dummy_size = 4 * PAGE_SIZE; let dummy_id1 = 22; let entry1 = Arc::new(AccountStorageEntry::new( - dummy_path, - dummy_slot, - dummy_id1, - dummy_size, + dummy_path, dummy_slot, dummy_id1, dummy_size, )); entry1.alive_bytes.store(3500, Ordering::Relaxed); @@ -11037,18 +11025,12 @@ pub mod tests { let dummy_id1 = 22; let entry1 = Arc::new(AccountStorageEntry::new( - dummy_path, - dummy_slot, - dummy_id1, - dummy_size, + dummy_path, dummy_slot, dummy_id1, dummy_size, )); let dummy_id2 = 44; let entry2 = Arc::new(AccountStorageEntry::new( - dummy_path, - dummy_slot, - dummy_id2, - dummy_size, + dummy_path, dummy_slot, dummy_id2, dummy_size, )); let mut recycle_stores = RecycleStores::default(); diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index ea8605e265..1ce1861cad 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -7320,8 +7320,7 @@ pub(crate) mod tests { .map(move |(_stake_pubkey, stake_account)| (stake_account, vote_account)) }) .map(|(stake_account, vote_account)| { - stake_state::calculate_points(stake_account, vote_account, None, true) - .unwrap_or(0) + stake_state::calculate_points(stake_account, vote_account, None, true).unwrap_or(0) }) .sum(); diff --git a/sdk/program/src/message.rs b/sdk/program/src/message.rs index aed75785a6..3b21246112 100644 --- a/sdk/program/src/message.rs +++ b/sdk/program/src/message.rs @@ -308,10 +308,8 @@ impl Message { nonce_account_pubkey: &Pubkey, nonce_authority_pubkey: &Pubkey, ) -> Self { - let nonce_ix = system_instruction::advance_nonce_account( - nonce_account_pubkey, - nonce_authority_pubkey, - ); + let nonce_ix = + system_instruction::advance_nonce_account(nonce_account_pubkey, nonce_authority_pubkey); instructions.insert(0, nonce_ix); Self::new(&instructions, payer) } diff --git a/upload-perf/src/upload-perf.rs b/upload-perf/src/upload-perf.rs index fbe0132a40..d983596884 100644 --- a/upload-perf/src/upload-perf.rs +++ b/upload-perf/src/upload-perf.rs @@ -76,11 +76,10 @@ fn main() { */ } - let last_median = get_last_metrics(&"median".to_string(), &db, &name, branch) + let last_median = + get_last_metrics(&"median".to_string(), &db, &name, branch).unwrap_or_default(); + let last_deviation = get_last_metrics(&"deviation".to_string(), &db, &name, branch) .unwrap_or_default(); - let last_deviation = - get_last_metrics(&"deviation".to_string(), &db, &name, branch) - .unwrap_or_default(); results.insert(name, (median, deviation, last_median, last_deviation)); }