More clippy

This commit is contained in:
Michael Vines
2019-10-02 18:33:01 -07:00
parent 9fe8c98047
commit f9f5bc2eb5
21 changed files with 97 additions and 90 deletions

View File

@ -266,7 +266,7 @@ impl Blocktree {
"Error: {:?} while submitting write batch for slot {:?} retrying...",
e, from_slot
);
Err(e)?;
return Err(e);
}
Ok(end)
}

View File

@ -809,7 +809,7 @@ impl ClusterInfo {
// by a valid tvu port location
let valid: Vec<_> = self.repair_peers();
if valid.is_empty() {
Err(ClusterInfoError::NoPeers)?;
return Err(ClusterInfoError::NoPeers.into());
}
let n = thread_rng().gen::<usize>() % valid.len();
let addr = valid[n].gossip; // send the request to the peer's gossip port

View File

@ -605,7 +605,7 @@ impl Blob {
"error sending {} byte packet to {:?}: {:?}",
p.meta.size, a, e
);
Err(e)?;
return Err(e.into());
}
}
}

View File

@ -448,7 +448,7 @@ impl ReplayStage {
trace!("new root {}", new_root);
if let Err(e) = root_bank_sender.send(rooted_banks) {
trace!("root_bank_sender failed: {:?}", e);
Err(e)?;
return Err(e.into());
}
}
Self::update_confidence_cache(bank.clone(), total_staked, lockouts_sender);

View File

@ -582,10 +582,9 @@ impl Replicator {
) -> Result<()> {
// make sure replicator has some balance
if client.poll_get_balance(&keypair.pubkey())? == 0 {
Err(io::Error::new(
io::ErrorKind::Other,
"keypair account has no balance",
))?
return Err(
io::Error::new(io::ErrorKind::Other, "keypair account has no balance").into(),
);
}
// check if the storage account exists
@ -705,10 +704,7 @@ impl Replicator {
.as_u64()
.unwrap())
} else {
Err(io::Error::new(
io::ErrorKind::Other,
"No RPC peers...".to_string(),
))?
Err(io::Error::new(io::ErrorKind::Other, "No RPC peers...".to_string()).into())
}
}
@ -889,10 +885,9 @@ impl Replicator {
// check if all the slots in the segment are complete
if !Self::segment_complete(start_slot, slots_per_segment, blocktree) {
Err(io::Error::new(
ErrorKind::Other,
"Unable to download the full segment",
))?
return Err(
io::Error::new(ErrorKind::Other, "Unable to download the full segment").into(),
);
}
Ok(start_slot)
}

View File

@ -572,7 +572,7 @@ impl Shredder {
shred_bufs.append(&mut pending_shreds);
if shred_bufs.len() != fec_set_size {
Err(reed_solomon_erasure::Error::TooFewShardsPresent)?;
return Err(reed_solomon_erasure::Error::TooFewShardsPresent);
}
let session = Session::new(num_data, num_coding).unwrap();
@ -623,7 +623,7 @@ impl Shredder {
};
if num_data.saturating_add(first_index) != last_index.saturating_add(1) {
Err(reed_solomon_erasure::Error::TooFewDataShards)?;
return Err(reed_solomon_erasure::Error::TooFewDataShards);
}
shreds.iter().map(|shred| &shred.payload).collect()

View File

@ -432,7 +432,7 @@ impl StorageStage {
}
Err(e) => {
info!("error encrypting file: {:?}", e);
Err(e)?;
return Err(e.into());
}
}
}

View File

@ -158,11 +158,11 @@ impl Tvu {
fork_confidence_cache,
);
let blockstream_service = if blockstream_unix_socket.is_some() {
let blockstream_service = if let Some(blockstream_unix_socket) = blockstream_unix_socket {
let blockstream_service = BlockstreamService::new(
blockstream_slot_receiver,
blocktree.clone(),
blockstream_unix_socket.unwrap(),
blockstream_unix_socket,
&exit,
);
Some(blockstream_service)

View File

@ -528,8 +528,8 @@ pub fn new_banks_from_blocktree(
dev_halt_at_slot,
);
if snapshot_config.is_some() {
bank_forks.set_snapshot_config(snapshot_config.unwrap());
if let Some(snapshot_config) = snapshot_config {
bank_forks.set_snapshot_config(snapshot_config);
}
(

View File

@ -77,8 +77,7 @@ fn recv_window<F>(
leader_schedule_cache: &Arc<LeaderScheduleCache>,
) -> Result<()>
where
F: Fn(&Shred, u64) -> bool,
F: Sync,
F: Fn(&Shred, u64) -> bool + Sync,
{
let timer = Duration::from_millis(200);
let mut packets = r.recv_timeout(timer)?;