Clippy cleanup for all targets and nighly rust (also support 1.44.0) (#10445)

* address warnings from 'rustup run beta cargo clippy --workspace'

minor refactoring in:
- cli/src/cli.rs
- cli/src/offline/blockhash_query.rs
- logger/src/lib.rs
- runtime/src/accounts_db.rs

expect some performance improvement AccountsDB::clean_accounts()

* address warnings from 'rustup run beta cargo clippy --workspace --tests'

* address warnings from 'rustup run nightly cargo clippy --workspace --all-targets'

* rustfmt

* fix warning stragglers

* properly fix clippy warnings test_vote_subscribe()
replace ref-to-arc with ref parameters where arc not cloned

* Remove lock around JsonRpcRequestProcessor (#10417)

automerge

* make ancestors parameter optional to avoid forcing construction of empty hash maps

Co-authored-by: Greg Fitzgerald <greg@solana.com>
This commit is contained in:
Kristofer Peterson
2020-06-09 01:38:14 +01:00
committed by GitHub
parent fa3a6c5584
commit e23340d89e
63 changed files with 258 additions and 308 deletions

View File

@ -20,7 +20,7 @@ fn bench_sigverify_shreds_sign_gpu(bencher: &mut Bencher) {
let mut packets = Packets::default();
packets.packets.set_pinnable();
let slot = 0xdeadc0de;
let slot = 0xdead_c0de;
// need to pin explicitly since the resize will not cause re-allocation
packets.packets.reserve_and_pin(NUM_PACKETS);
packets.packets.resize(NUM_PACKETS, Packet::default());
@ -54,7 +54,7 @@ fn bench_sigverify_shreds_sign_gpu(bencher: &mut Bencher) {
#[bench]
fn bench_sigverify_shreds_sign_cpu(bencher: &mut Bencher) {
let mut packets = Packets::default();
let slot = 0xdeadc0de;
let slot = 0xdead_c0de;
packets.packets.resize(NUM_PACKETS, Packet::default());
for p in packets.packets.iter_mut() {
let shred = Shred::new_from_data(

View File

@ -621,7 +621,7 @@ impl Blockstore {
metrics: &mut BlockstoreInsertionMetrics,
) -> Result<()>
where
F: Fn(Shred) -> (),
F: Fn(Shred),
{
let mut total_start = Measure::start("Total elapsed");
let mut start = Measure::start("Blockstore lock");
@ -918,7 +918,7 @@ impl Blockstore {
is_recovered: bool,
) -> bool
where
F: Fn(Shred) -> (),
F: Fn(Shred),
{
let slot = shred.slot();
let shred_index = u64::from(shred.index());
@ -1533,7 +1533,7 @@ impl Blockstore {
let blockhash = get_last_hash(slot_entries.iter())
.unwrap_or_else(|| panic!("Rooted slot {:?} must have blockhash", slot));
let rewards = self.rewards_cf.get(slot)?.unwrap_or_else(|| vec![]);
let rewards = self.rewards_cf.get(slot)?.unwrap_or_else(Vec::new);
let block = ConfirmedBlock {
previous_blockhash: previous_blockhash.to_string(),
@ -1743,7 +1743,7 @@ impl Blockstore {
"blockstore-rpc-api",
("method", "get_confirmed_transaction".to_string(), String)
);
if let Some((slot, status)) = self.get_transaction_status(signature.clone())? {
if let Some((slot, status)) = self.get_transaction_status(signature)? {
let transaction = self.find_transaction_in_slot(slot, signature)?
.expect("Transaction to exist in slot entries if it exists in statuses and hasn't been cleaned up");
let encoding = encoding.unwrap_or(TransactionEncoding::Json);
@ -4948,7 +4948,7 @@ pub mod tests {
// Insert will fail, slot < root
blockstore
.insert_shreds(shreds1.clone()[..].to_vec(), None, false)
.insert_shreds(shreds1[..].to_vec(), None, false)
.unwrap();
assert!(blockstore.get_data_shred(1, 0).unwrap().is_none());
@ -5229,7 +5229,7 @@ pub mod tests {
stakes.insert(keypair.pubkey(), (1 + i as u64, Account::default()));
}
let slot_duration = Duration::from_millis(400);
let block_time_slot_3 = blockstore.get_block_time(3, slot_duration.clone(), &stakes);
let block_time_slot_3 = blockstore.get_block_time(3, slot_duration, &stakes);
let mut total_stake = 0;
let mut expected_time: u64 = (0..6)
@ -5246,7 +5246,7 @@ pub mod tests {
assert_eq!(block_time_slot_3.unwrap().unwrap() as u64, expected_time);
assert_eq!(
blockstore
.get_block_time(8, slot_duration.clone(), &stakes)
.get_block_time(8, slot_duration, &stakes)
.unwrap()
.unwrap() as u64,
expected_time + 2 // At 400ms block duration, 5 slots == 2sec

View File

@ -257,7 +257,7 @@ pub enum BlockstoreProcessorError {
}
/// Callback for accessing bank state while processing the blockstore
pub type ProcessCallback = Arc<dyn Fn(&Bank) -> () + Sync + Send>;
pub type ProcessCallback = Arc<dyn Fn(&Bank) + Sync + Send>;
#[derive(Default, Clone)]
pub struct ProcessOptions {

View File

@ -133,7 +133,7 @@ fn slot_key_data_for_gpu<
let key = slot_keys.get(slot).unwrap();
keys_to_slots
.entry(*key)
.or_insert_with(|| vec![])
.or_insert_with(Vec::new)
.push(*slot);
}
}

View File

@ -177,7 +177,7 @@ fn sort_data_coding_into_fec_sets(
data_slot_and_index.insert(key);
let fec_entry = fec_data
.entry(shred.common_header.fec_set_index)
.or_insert_with(|| vec![]);
.or_insert_with(Vec::new);
fec_entry.push(shred);
}
for shred in coding_shreds {
@ -188,7 +188,7 @@ fn sort_data_coding_into_fec_sets(
coding_slot_and_index.insert(key);
let fec_entry = fec_coding
.entry(shred.common_header.fec_set_index)
.or_insert_with(|| vec![]);
.or_insert_with(Vec::new);
fec_entry.push(shred);
}
}