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:
		
							parent
							
								
									bacc38c3da
								
							
						
					
					
						commit
						cb47388ad7
					
				| @ -306,8 +306,8 @@ where | |||||||
|             })?; |             })?; | ||||||
| 
 | 
 | ||||||
|         let genesis = BeaconSnapshot { |         let genesis = BeaconSnapshot { | ||||||
|             beacon_block_root, |  | ||||||
|             beacon_block, |             beacon_block, | ||||||
|  |             beacon_block_root, | ||||||
|             beacon_state, |             beacon_state, | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -612,11 +612,9 @@ fn collect_valid_votes<T: EthSpec>( | |||||||
|         .eth1_data_votes |         .eth1_data_votes | ||||||
|         .iter() |         .iter() | ||||||
|         .filter_map(|vote| { |         .filter_map(|vote| { | ||||||
|             if let Some(block_num) = votes_to_consider.get(vote) { |             votes_to_consider | ||||||
|                 Some((vote.clone(), *block_num)) |                 .get(vote) | ||||||
|             } else { |                 .map(|block_num| (vote.clone(), *block_num)) | ||||||
|                 None |  | ||||||
|             } |  | ||||||
|         }) |         }) | ||||||
|         .for_each(|(eth1_data, block_number)| { |         .for_each(|(eth1_data, block_number)| { | ||||||
|             valid_votes |             valid_votes | ||||||
|  | |||||||
| @ -73,7 +73,7 @@ impl FromStr for Eth1Id { | |||||||
|     type Err = String; |     type Err = String; | ||||||
| 
 | 
 | ||||||
|     fn from_str(s: &str) -> Result<Self, Self::Err> { |     fn from_str(s: &str) -> Result<Self, Self::Err> { | ||||||
|         u64::from_str_radix(s, 10) |         s.parse::<u64>() | ||||||
|             .map(Into::into) |             .map(Into::into) | ||||||
|             .map_err(|e| format!("Failed to parse eth1 network id {}", e)) |             .map_err(|e| format!("Failed to parse eth1 network id {}", e)) | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -299,7 +299,7 @@ mod tests { | |||||||
|         let sk_bytes = hex::decode(sk_hex).unwrap(); |         let sk_bytes = hex::decode(sk_hex).unwrap(); | ||||||
|         let secret = discv5::enr::ed25519_dalek::SecretKey::from_bytes(&sk_bytes).unwrap(); |         let secret = discv5::enr::ed25519_dalek::SecretKey::from_bytes(&sk_bytes).unwrap(); | ||||||
|         let public = discv5::enr::ed25519_dalek::PublicKey::from(&secret); |         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 libp2p_sk = libp2p::identity::ed25519::SecretKey::from_bytes(sk_bytes).unwrap(); | ||||||
|         let ed25519_kp: libp2p::identity::ed25519::Keypair = libp2p_sk.into(); |         let ed25519_kp: libp2p::identity::ed25519::Keypair = libp2p_sk.into(); | ||||||
|  | |||||||
| @ -233,9 +233,9 @@ impl<TSpec: EthSpec> Service<TSpec> { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         let service = Service { |         let service = Service { | ||||||
|             local_peer_id, |  | ||||||
|             bandwidth, |  | ||||||
|             swarm, |             swarm, | ||||||
|  |             bandwidth, | ||||||
|  |             local_peer_id, | ||||||
|             log, |             log, | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -81,8 +81,8 @@ impl GossipTopic { | |||||||
|     pub fn new(kind: GossipKind, encoding: GossipEncoding, fork_digest: [u8; 4]) -> Self { |     pub fn new(kind: GossipKind, encoding: GossipEncoding, fork_digest: [u8; 4]) -> Self { | ||||||
|         GossipTopic { |         GossipTopic { | ||||||
|             encoding, |             encoding, | ||||||
|             kind, |  | ||||||
|             fork_digest, |             fork_digest, | ||||||
|  |             kind, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -135,8 +135,8 @@ impl GossipTopic { | |||||||
| 
 | 
 | ||||||
|             return Ok(GossipTopic { |             return Ok(GossipTopic { | ||||||
|                 encoding, |                 encoding, | ||||||
|                 kind, |  | ||||||
|                 fork_digest, |                 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> { | fn committee_topic_index(topic: &str) -> Option<SubnetId> { | ||||||
|     if topic.starts_with(BEACON_ATTESTATION_PREFIX) { |     if topic.starts_with(BEACON_ATTESTATION_PREFIX) { | ||||||
|         return Some(SubnetId::new( |         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 |     None | ||||||
|  | |||||||
| @ -1355,7 +1355,7 @@ pub fn serve<T: BeaconChainTypes>( | |||||||
|                 let heads = chain |                 let heads = chain | ||||||
|                     .heads() |                     .heads() | ||||||
|                     .into_iter() |                     .into_iter() | ||||||
|                     .map(|(root, slot)| api_types::ChainHeadData { root, slot }) |                     .map(|(root, slot)| api_types::ChainHeadData { slot, root }) | ||||||
|                     .collect::<Vec<_>>(); |                     .collect::<Vec<_>>(); | ||||||
|                 Ok(api_types::GenericResponse::from(heads)) |                 Ok(api_types::GenericResponse::from(heads)) | ||||||
|             }) |             }) | ||||||
| @ -1623,10 +1623,10 @@ pub fn serve<T: BeaconChainTypes>( | |||||||
|                     }); |                     }); | ||||||
| 
 | 
 | ||||||
|                 Ok(api_types::GenericResponse::from(api_types::PeerCount { |                 Ok(api_types::GenericResponse::from(api_types::PeerCount { | ||||||
|                     disconnecting, |  | ||||||
|                     connecting, |  | ||||||
|                     connected, |                     connected, | ||||||
|  |                     connecting, | ||||||
|                     disconnected, |                     disconnected, | ||||||
|  |                     disconnecting, | ||||||
|                 })) |                 })) | ||||||
|             }) |             }) | ||||||
|         }); |         }); | ||||||
|  | |||||||
| @ -197,10 +197,7 @@ impl<T: BeaconChainTypes> Worker<T> { | |||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         // remove all skip slots
 |         // remove all skip slots
 | ||||||
|         let block_roots = block_roots |         let block_roots = block_roots.into_iter().flatten().collect::<Vec<_>>(); | ||||||
|             .into_iter() |  | ||||||
|             .filter_map(|root| root) |  | ||||||
|             .collect::<Vec<_>>(); |  | ||||||
| 
 | 
 | ||||||
|         let mut blocks_sent = 0; |         let mut blocks_sent = 0; | ||||||
|         for root in block_roots { |         for root in block_roots { | ||||||
|  | |||||||
| @ -572,10 +572,8 @@ macro_rules! math_tests { | |||||||
|         #[test] |         #[test] | ||||||
|         fn checked_div() { |         fn checked_div() { | ||||||
|             let assert_checked_div = |a: u64, b: u64, result: Option<u64>| { |             let assert_checked_div = |a: u64, b: u64, result: Option<u64>| { | ||||||
|                 let division_result_as_u64 = match $type(a).safe_div($type(b)).ok() { |                 let division_result_as_u64 = | ||||||
|                     None => None, |                     $type(a).safe_div($type(b)).ok().map(|val| val.as_u64()); | ||||||
|                     Some(val) => Some(val.as_u64()), |  | ||||||
|                 }; |  | ||||||
|                 assert_eq!(division_result_as_u64, result); |                 assert_eq!(division_result_as_u64, result); | ||||||
|             }; |             }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -38,10 +38,10 @@ impl<E: EthSpec> Slasher<E> { | |||||||
|         let block_queue = BlockQueue::default(); |         let block_queue = BlockQueue::default(); | ||||||
|         Ok(Self { |         Ok(Self { | ||||||
|             db, |             db, | ||||||
|             attester_slashings, |  | ||||||
|             proposer_slashings, |  | ||||||
|             attestation_queue, |             attestation_queue, | ||||||
|             block_queue, |             block_queue, | ||||||
|  |             attester_slashings, | ||||||
|  |             proposer_slashings, | ||||||
|             config, |             config, | ||||||
|             log, |             log, | ||||||
|         }) |         }) | ||||||
|  | |||||||
| @ -62,8 +62,8 @@ impl GanacheInstance { | |||||||
|         child.stdout = Some(reader.into_inner()); |         child.stdout = Some(reader.into_inner()); | ||||||
| 
 | 
 | ||||||
|         Ok(Self { |         Ok(Self { | ||||||
|             child, |  | ||||||
|             port, |             port, | ||||||
|  |             child, | ||||||
|             web3, |             web3, | ||||||
|             network_id, |             network_id, | ||||||
|             chain_id, |             chain_id, | ||||||
|  | |||||||
| @ -104,7 +104,7 @@ impl DepositContract { | |||||||
|         })?; |         })?; | ||||||
|         Contract::from_json(web3.clone().eth(), address, ABI) |         Contract::from_json(web3.clone().eth(), address, ABI) | ||||||
|             .map_err(|e| format!("Failed to init contract: {:?}", e)) |             .map_err(|e| format!("Failed to init contract: {:?}", e)) | ||||||
|             .map(move |contract| Self { contract, web3 }) |             .map(move |contract| Self { web3, contract }) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /// The deposit contract's address in `0x00ab...` format.
 |     /// The deposit contract's address in `0x00ab...` format.
 | ||||||
|  | |||||||
| @ -83,8 +83,8 @@ impl ExitTest { | |||||||
| 
 | 
 | ||||||
|         TestVector { |         TestVector { | ||||||
|             title, |             title, | ||||||
|             block, |  | ||||||
|             pre_state, |             pre_state, | ||||||
|  |             block, | ||||||
|             post_state, |             post_state, | ||||||
|             error, |             error, | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -133,7 +133,7 @@ impl ApiSecret { | |||||||
|             )); |             )); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         Ok(Self { sk, pk }) |         Ok(Self { pk, sk }) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /// Returns the public key of `self` as a 0x-prefixed hex string.
 |     /// Returns the public key of `self` as a 0x-prefixed hex string.
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user