diff --git a/beacon_node/client/src/config.rs b/beacon_node/client/src/config.rs index bb9e196f7e..13614af12e 100644 --- a/beacon_node/client/src/config.rs +++ b/beacon_node/client/src/config.rs @@ -149,10 +149,8 @@ impl Config { pub fn get_existing_legacy_data_dir(&self) -> Option { dirs::home_dir() .map(|home_dir| home_dir.join(&self.data_dir)) - // Return `None` if the directory does not exists. - .filter(|dir| dir.exists()) - // Return `None` if the legacy directory is identical to the modern. - .filter(|dir| *dir != self.get_modern_data_dir()) + // Return `None` if the legacy directory does not exist or if it is identical to the modern. + .filter(|dir| dir.exists() && *dir != self.get_modern_data_dir()) } /// Returns the core path for the client. diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index b153e9a274..26fb77b1bd 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -121,8 +121,7 @@ impl ApiTester { harness.chain.slot().unwrap(), ) .into_iter() - .map(|vec| vec.into_iter().map(|(attestation, _subnet_id)| attestation)) - .flatten() + .flat_map(|vec| vec.into_iter().map(|(attestation, _subnet_id)| attestation)) .collect::>(); assert!( @@ -244,8 +243,7 @@ impl ApiTester { harness.chain.slot().unwrap(), ) .into_iter() - .map(|vec| vec.into_iter().map(|(attestation, _subnet_id)| attestation)) - .flatten() + .flat_map(|vec| vec.into_iter().map(|(attestation, _subnet_id)| attestation)) .collect::>(); let attester_slashing = harness.make_attester_slashing(vec![0, 1]); @@ -2390,8 +2388,7 @@ impl ApiTester { .unwrap(); let attesting_validators: Vec = committees .into_iter() - .map(|committee| committee.committee.iter().cloned()) - .flatten() + .flat_map(|committee| committee.committee.iter().cloned()) .collect(); // All attesters should now be considered live let expected = expected diff --git a/beacon_node/lighthouse_network/src/discovery/enr.rs b/beacon_node/lighthouse_network/src/discovery/enr.rs index 1d542a7f39..b513ede59f 100644 --- a/beacon_node/lighthouse_network/src/discovery/enr.rs +++ b/beacon_node/lighthouse_network/src/discovery/enr.rs @@ -210,10 +210,8 @@ pub fn load_enr_from_disk(dir: &Path) -> Result { let mut enr_string = String::new(); match enr_file.read_to_string(&mut enr_string) { Err(_) => Err("Could not read ENR from file".to_string()), - Ok(_) => match Enr::from_str(&enr_string) { - Ok(disk_enr) => Ok(disk_enr), - Err(e) => Err(format!("ENR from file could not be decoded: {:?}", e)), - }, + Ok(_) => Enr::from_str(&enr_string) + .map_err(|e| format!("ENR from file could not be decoded: {:?}", e)), } } diff --git a/validator_client/src/duties_service.rs b/validator_client/src/duties_service.rs index 6428034d8b..f8ca5a3d44 100644 --- a/validator_client/src/duties_service.rs +++ b/validator_client/src/duties_service.rs @@ -646,17 +646,18 @@ async fn poll_beacon_attesters_for_epoch( response .data .into_iter() - .filter(|duty| local_pubkeys.contains(&duty.pubkey)) .filter(|duty| { - // Only update the duties if either is true: - // - // - There were no known duties for this epoch. - // - The dependent root has changed, signalling a re-org. - attesters.get(&duty.pubkey).map_or(true, |duties| { - duties - .get(&epoch) - .map_or(true, |(prior, _)| *prior != dependent_root) - }) + local_pubkeys.contains(&duty.pubkey) && { + // Only update the duties if either is true: + // + // - There were no known duties for this epoch. + // - The dependent root has changed, signalling a re-org. + attesters.get(&duty.pubkey).map_or(true, |duties| { + duties + .get(&epoch) + .map_or(true, |(prior, _)| *prior != dependent_root) + }) + } }) .collect::>() }; diff --git a/validator_client/src/http_api/tests/keystores.rs b/validator_client/src/http_api/tests/keystores.rs index 69410456f8..aa633d4de1 100644 --- a/validator_client/src/http_api/tests/keystores.rs +++ b/validator_client/src/http_api/tests/keystores.rs @@ -983,8 +983,7 @@ fn delete_concurrent_with_signing() { for interchange in collected_slashing_protection .into_iter() - .map(Result::unwrap) - .flatten() + .flat_map(Result::unwrap) { for validator_data in interchange.data { slashing_protection_map