Fix clippy lints
This commit is contained in:
		
							parent
							
								
									62640ad691
								
							
						
					
					
						commit
						3876e29f6e
					
				| @ -8,7 +8,7 @@ pub fn genesis_beacon_block(state_root: Hash256, spec: &ChainSpec) -> BeaconBloc | ||||
|     BeaconBlock { | ||||
|         slot: spec.initial_slot_number, | ||||
|         parent_root: spec.zero_hash, | ||||
|         state_root: state_root, | ||||
|         state_root, | ||||
|         randao_reveal: spec.zero_hash, | ||||
|         candidate_pow_receipt_root: spec.zero_hash, | ||||
|         signature: genesis_signature(), | ||||
|  | ||||
| @ -15,8 +15,8 @@ pub enum ForkChoiceError { | ||||
| } | ||||
| 
 | ||||
| pub fn naive_fork_choice<T>( | ||||
|     head_block_hashes: &Vec<Hash256>, | ||||
|     block_store: Arc<BeaconBlockStore<T>>, | ||||
|     head_block_hashes: &[Hash256], | ||||
|     block_store: &Arc<BeaconBlockStore<T>>, | ||||
| ) -> Result<Option<usize>, ForkChoiceError> | ||||
| where | ||||
|     T: ClientDB + Sized, | ||||
| @ -28,7 +28,7 @@ where | ||||
|      */ | ||||
|     for (index, block_hash) in head_block_hashes.iter().enumerate() { | ||||
|         let ssz = block_store | ||||
|             .get(&block_hash.to_vec()[..])? | ||||
|             .get(&block_hash)? | ||||
|             .ok_or(ForkChoiceError::MissingBlock)?; | ||||
|         let (block, _) = BeaconBlock::ssz_decode(&ssz, 0)?; | ||||
|         head_blocks.push((index, block)); | ||||
|  | ||||
| @ -64,7 +64,7 @@ impl ChainSpec { | ||||
|              * Intialization parameters | ||||
|              */ | ||||
|             initial_validators: initial_validators_for_testing(), | ||||
|             genesis_time: 1544672897, | ||||
|             genesis_time: 1_544_672_897, | ||||
|             processed_pow_receipt_root: Hash256::from("pow_root".as_bytes()), | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -5,7 +5,7 @@ use rand::RngCore; | ||||
| use ssz::{Decodable, DecodeError, Encodable, SszStream}; | ||||
| use std::convert; | ||||
| 
 | ||||
| #[derive(Debug, PartialEq, Clone)] | ||||
| #[derive(Debug, PartialEq, Clone, Copy)] | ||||
| pub enum ValidatorStatus { | ||||
|     PendingActivation, | ||||
|     Active, | ||||
| @ -87,7 +87,7 @@ impl<T: RngCore> TestRandom<T> for ValidatorStatus { | ||||
|             ValidatorStatus::Withdrawn, | ||||
|             ValidatorStatus::Penalized, | ||||
|         ]; | ||||
|         options[(rng.next_u32() as usize) % options.len()].clone() | ||||
|         options[(rng.next_u32() as usize) % options.len()] | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -6,7 +6,7 @@ use bls_aggregates::AggregateSignature as RawAggregateSignature; | ||||
| ///
 | ||||
| /// This struct is a wrapper upon a base type and provides helper functions (e.g., SSZ
 | ||||
| /// serialization).
 | ||||
| #[derive(Debug, PartialEq, Clone)] | ||||
| #[derive(Debug, PartialEq, Clone, Default)] | ||||
| pub struct AggregateSignature(RawAggregateSignature); | ||||
| 
 | ||||
| impl AggregateSignature { | ||||
|  | ||||
| @ -26,7 +26,7 @@ impl SystemTimeSlotClock { | ||||
|         if slot_duration_seconds == 0 { | ||||
|             Err(Error::SlotDurationIsZero) | ||||
|         } else { | ||||
|             Ok(SystemTimeSlotClock { | ||||
|             Ok(Self { | ||||
|                 genesis_seconds, | ||||
|                 slot_duration_seconds, | ||||
|             }) | ||||
|  | ||||
| @ -23,25 +23,31 @@ where | ||||
|             .present_slot()? | ||||
|             .ok_or(Error::PresentSlotIsNone)?; | ||||
|         let parent_root = self.canonical_leaf_block; | ||||
|         let parent_block = self | ||||
|         let parent_block_reader = self | ||||
|             .block_store | ||||
|             .get_deserialized(&parent_root)? | ||||
|             .ok_or(Error::DBError("Block not found.".to_string()))?; | ||||
|         let parent_state = self | ||||
|             .get_reader(&parent_root)? | ||||
|             .ok_or_else(|| Error::DBError("Block not found.".to_string()))?; | ||||
|         let parent_state_reader = self | ||||
|             .state_store | ||||
|             .get_deserialized(&parent_block.state_root())? | ||||
|             .ok_or(Error::DBError("State not found.".to_string()))?; | ||||
|             .get_reader(&parent_block_reader.state_root())? | ||||
|             .ok_or_else(|| Error::DBError("State not found.".to_string()))?; | ||||
| 
 | ||||
|         let parent_block = parent_block_reader | ||||
|             .into_beacon_block() | ||||
|             .ok_or_else(|| Error::DBError("Bad parent block SSZ.".to_string()))?; | ||||
|         let mut block = BeaconBlock { | ||||
|             slot: present_slot, | ||||
|             parent_root, | ||||
|             state_root: Hash256::zero(), // Updated after the state is calculated.
 | ||||
|             ..parent_block.to_beacon_block() | ||||
|             ..parent_block | ||||
|         }; | ||||
| 
 | ||||
|         let parent_state = parent_state_reader | ||||
|             .into_beacon_state() | ||||
|             .ok_or_else(|| Error::DBError("Bad parent block SSZ.".to_string()))?; | ||||
|         let state = BeaconState { | ||||
|             slot: present_slot, | ||||
|             ..parent_state.to_beacon_state() | ||||
|             ..parent_state | ||||
|         }; | ||||
|         let state_root = state.canonical_root(); | ||||
| 
 | ||||
|  | ||||
| @ -55,7 +55,7 @@ where | ||||
|         block_store.put(&block_root, &ssz_encode(&genesis_block)[..])?; | ||||
| 
 | ||||
|         let mut leaf_blocks = HashSet::new(); | ||||
|         leaf_blocks.insert(block_root.clone()); | ||||
|         leaf_blocks.insert(block_root); | ||||
| 
 | ||||
|         Ok(Self { | ||||
|             block_store, | ||||
|  | ||||
| @ -20,6 +20,7 @@ macro_rules! impl_crud_for_store { | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| #[allow(unused_macros)] | ||||
| macro_rules! test_crud_for_store { | ||||
|     ($store: ident, $db_column: expr) => { | ||||
|         #[test] | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user