Add various fixes to clippy lints

Thou shalt appease clippy
This commit is contained in:
Paul Hauner
2019-06-10 11:01:25 -04:00
parent a9284bec18
commit e550c0218f
37 changed files with 72 additions and 82 deletions

View File

@@ -216,9 +216,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.iter()
.map(|root| match self.get_block(root)? {
Some(block) => Ok(block.body),
None => Err(Error::DBInconsistent(
format!("Missing block: {}", root).into(),
)),
None => Err(Error::DBInconsistent(format!("Missing block: {}", root))),
})
.collect();

View File

@@ -57,7 +57,7 @@ impl<T: EthSpec, U: Store> Iterator for BlockRootsIterator<T, U> {
return None;
}
self.slot = self.slot - 1;
self.slot -= 1;
match self.beacon_state.get_block_root(self.slot) {
Ok(root) => Some(*root),
@@ -73,7 +73,7 @@ impl<T: EthSpec, U: Store> Iterator for BlockRootsIterator<T, U> {
self.beacon_state.get_block_root(self.slot).ok().cloned()
}
_ => return None,
_ => None,
}
}
}

View File

@@ -57,12 +57,12 @@ impl Config {
pub fn apply_cli_args(&mut self, args: &ArgMatches) -> Result<(), &'static str> {
if let Some(listen_address_str) = args.value_of("listen-address") {
let listen_addresses = listen_address_str.split(",").map(Into::into).collect();
let listen_addresses = listen_address_str.split(',').map(Into::into).collect();
self.listen_addresses = listen_addresses;
}
if let Some(boot_addresses_str) = args.value_of("boot-nodes") {
let boot_addresses = boot_addresses_str.split(",").map(Into::into).collect();
let boot_addresses = boot_addresses_str.split(',').map(Into::into).collect();
self.boot_nodes = boot_addresses;
}

View File

@@ -42,7 +42,7 @@ impl RequestId {
}
/// Return the previous id.
pub fn previous(&self) -> Self {
pub fn previous(self) -> Self {
Self(self.0 - 1)
}
}
@@ -220,7 +220,7 @@ impl Encode for RPCEvent {
} => SszContainer {
is_request: true,
id: (*id).into(),
other: (*method_id).into(),
other: *method_id,
bytes: match body {
RPCRequest::Hello(body) => body.as_ssz_bytes(),
RPCRequest::Goodbye(body) => body.as_ssz_bytes(),
@@ -237,7 +237,7 @@ impl Encode for RPCEvent {
} => SszContainer {
is_request: false,
id: (*id).into(),
other: (*method_id).into(),
other: *method_id,
bytes: match result {
RPCResponse::Hello(response) => response.as_ssz_bytes(),
RPCResponse::BeaconBlockRoots(response) => response.as_ssz_bytes(),

View File

@@ -155,7 +155,7 @@ impl<T: BeaconChainTypes + 'static> MessageHandler<T> {
if self
.network_context
.outstanding_outgoing_request_ids
.remove(&(peer_id.clone(), id.clone()))
.remove(&(peer_id.clone(), id))
.is_none()
{
warn!(
@@ -250,7 +250,7 @@ impl NetworkContext {
let id = self.generate_request_id(&peer_id);
self.outstanding_outgoing_request_ids
.insert((peer_id.clone(), id.clone()), Instant::now());
.insert((peer_id.clone(), id), Instant::now());
self.send_rpc_event(
peer_id,