Updated to comply with new clippy formatting rules (#2336)

## Issue Addressed

The latest version of Rust has new clippy rules & the codebase isn't up to date with them.

## Proposed Changes

Small formatting changes that clippy tells me are functionally equivalent
This commit is contained in:
ethDreamer
2021-05-10 00:53:09 +00:00
parent bacc38c3da
commit cb47388ad7
14 changed files with 26 additions and 30 deletions

View File

@@ -306,8 +306,8 @@ where
})?;
let genesis = BeaconSnapshot {
beacon_block_root,
beacon_block,
beacon_block_root,
beacon_state,
};

View File

@@ -612,11 +612,9 @@ fn collect_valid_votes<T: EthSpec>(
.eth1_data_votes
.iter()
.filter_map(|vote| {
if let Some(block_num) = votes_to_consider.get(vote) {
Some((vote.clone(), *block_num))
} else {
None
}
votes_to_consider
.get(vote)
.map(|block_num| (vote.clone(), *block_num))
})
.for_each(|(eth1_data, block_number)| {
valid_votes

View File

@@ -73,7 +73,7 @@ impl FromStr for Eth1Id {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
u64::from_str_radix(s, 10)
s.parse::<u64>()
.map(Into::into)
.map_err(|e| format!("Failed to parse eth1 network id {}", e))
}

View File

@@ -299,7 +299,7 @@ mod tests {
let sk_bytes = hex::decode(sk_hex).unwrap();
let secret = discv5::enr::ed25519_dalek::SecretKey::from_bytes(&sk_bytes).unwrap();
let public = discv5::enr::ed25519_dalek::PublicKey::from(&secret);
let keypair = discv5::enr::ed25519_dalek::Keypair { public, secret };
let keypair = discv5::enr::ed25519_dalek::Keypair { secret, public };
let libp2p_sk = libp2p::identity::ed25519::SecretKey::from_bytes(sk_bytes).unwrap();
let ed25519_kp: libp2p::identity::ed25519::Keypair = libp2p_sk.into();

View File

@@ -233,9 +233,9 @@ impl<TSpec: EthSpec> Service<TSpec> {
}
let service = Service {
local_peer_id,
bandwidth,
swarm,
bandwidth,
local_peer_id,
log,
};

View File

@@ -81,8 +81,8 @@ impl GossipTopic {
pub fn new(kind: GossipKind, encoding: GossipEncoding, fork_digest: [u8; 4]) -> Self {
GossipTopic {
encoding,
kind,
fork_digest,
kind,
}
}
@@ -135,8 +135,8 @@ impl GossipTopic {
return Ok(GossipTopic {
encoding,
kind,
fork_digest,
kind,
});
}
@@ -195,7 +195,10 @@ pub fn subnet_id_from_topic_hash(topic_hash: &TopicHash) -> Option<SubnetId> {
fn committee_topic_index(topic: &str) -> Option<SubnetId> {
if topic.starts_with(BEACON_ATTESTATION_PREFIX) {
return Some(SubnetId::new(
u64::from_str_radix(topic.trim_start_matches(BEACON_ATTESTATION_PREFIX), 10).ok()?,
topic
.trim_start_matches(BEACON_ATTESTATION_PREFIX)
.parse::<u64>()
.ok()?,
));
}
None

View File

@@ -1355,7 +1355,7 @@ pub fn serve<T: BeaconChainTypes>(
let heads = chain
.heads()
.into_iter()
.map(|(root, slot)| api_types::ChainHeadData { root, slot })
.map(|(root, slot)| api_types::ChainHeadData { slot, root })
.collect::<Vec<_>>();
Ok(api_types::GenericResponse::from(heads))
})
@@ -1623,10 +1623,10 @@ pub fn serve<T: BeaconChainTypes>(
});
Ok(api_types::GenericResponse::from(api_types::PeerCount {
disconnecting,
connecting,
connected,
connecting,
disconnected,
disconnecting,
}))
})
});

View File

@@ -197,10 +197,7 @@ impl<T: BeaconChainTypes> Worker<T> {
};
// remove all skip slots
let block_roots = block_roots
.into_iter()
.filter_map(|root| root)
.collect::<Vec<_>>();
let block_roots = block_roots.into_iter().flatten().collect::<Vec<_>>();
let mut blocks_sent = 0;
for root in block_roots {