mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-29 02:33:48 +00:00
Update for clippy 1.50 (#2193)
## Issue Addressed NA ## Proposed Changes Rust 1.50 has landed 🎉 The shiny new `clippy` peers down upon us mere mortals with disgust. Brutish peasants wrapping our `usize`s in superfluous `Option`s... tsk tsk. I've performed the goat sacrifice and corrected our evil ways in this PR. Tonight we shall pray that Github Actions bestows the almighty green tick upon us. ## Additional Info NA Co-authored-by: realbigsean <seananderson33@gmail.com> Co-authored-by: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
@@ -584,13 +584,13 @@ impl<T: BeaconChainTypes> AttestationService<T> {
|
||||
/// We don't keep track of a specific validator to random subnet, rather the ratio of active
|
||||
/// validators to random subnets. So when a validator goes offline, we can simply remove the
|
||||
/// allocated amount of random subnets.
|
||||
fn handle_known_validator_expiry(&mut self) -> Result<(), ()> {
|
||||
fn handle_known_validator_expiry(&mut self) {
|
||||
let spec = &self.beacon_chain.spec;
|
||||
let subnet_count = spec.attestation_subnet_count;
|
||||
let random_subnets_per_validator = spec.random_subnets_per_validator;
|
||||
if self.known_validators.len() as u64 * random_subnets_per_validator >= subnet_count {
|
||||
// have too many validators, ignore
|
||||
return Ok(());
|
||||
return;
|
||||
}
|
||||
|
||||
let subscribed_subnets = self.random_subnets.keys().cloned().collect::<Vec<_>>();
|
||||
@@ -616,7 +616,6 @@ impl<T: BeaconChainTypes> AttestationService<T> {
|
||||
.push_back(AttServiceMessage::EnrRemove(*subnet_id));
|
||||
self.random_subnets.remove(subnet_id);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,11 @@ async fn subscribe_current_slot_wait_for_unsubscribe() {
|
||||
let events = get_events(&mut attestation_service, None, 1).await;
|
||||
assert_matches!(
|
||||
events[..3],
|
||||
[AttServiceMessage::DiscoverPeers(_), AttServiceMessage::Subscribe(_any1), AttServiceMessage::EnrAdd(_any3)]
|
||||
[
|
||||
AttServiceMessage::DiscoverPeers(_),
|
||||
AttServiceMessage::Subscribe(_any1),
|
||||
AttServiceMessage::EnrAdd(_any3)
|
||||
]
|
||||
);
|
||||
|
||||
// If the long lived and short lived subnets are the same, there should be no more events
|
||||
@@ -281,7 +285,11 @@ async fn test_same_subnet_unsubscription() {
|
||||
let events = get_events(&mut attestation_service, None, 1).await;
|
||||
assert_matches!(
|
||||
events[..3],
|
||||
[AttServiceMessage::DiscoverPeers(_), AttServiceMessage::Subscribe(_any1), AttServiceMessage::EnrAdd(_any3)]
|
||||
[
|
||||
AttServiceMessage::DiscoverPeers(_),
|
||||
AttServiceMessage::Subscribe(_any1),
|
||||
AttServiceMessage::EnrAdd(_any3)
|
||||
]
|
||||
);
|
||||
|
||||
let expected = AttServiceMessage::Subscribe(subnet_id1);
|
||||
|
||||
@@ -52,11 +52,7 @@ pub fn construct_upnp_mappings<T: EthSpec>(
|
||||
// Just use the first IP of the first interface that is not a loopback and not an
|
||||
// ipv6 address.
|
||||
if !interface.is_loopback() {
|
||||
if let IpAddr::V4(_) = interface.ip() {
|
||||
Some(interface.ip())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
interface.ip().is_ipv4().then(|| interface.ip())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
||||
log: network_log,
|
||||
};
|
||||
|
||||
spawn_service(executor, network_service)?;
|
||||
spawn_service(executor, network_service);
|
||||
|
||||
Ok((network_globals, network_send))
|
||||
}
|
||||
@@ -228,7 +228,7 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
||||
fn spawn_service<T: BeaconChainTypes>(
|
||||
executor: task_executor::TaskExecutor,
|
||||
mut service: NetworkService<T>,
|
||||
) -> error::Result<()> {
|
||||
) {
|
||||
let mut exit_rx = executor.exit();
|
||||
let mut shutdown_sender = executor.shutdown_sender();
|
||||
|
||||
@@ -570,8 +570,6 @@ fn spawn_service<T: BeaconChainTypes>(
|
||||
metrics::update_bandwidth_metrics(service.libp2p.bandwidth.clone());
|
||||
}
|
||||
}, "network");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Returns a `Sleep` that triggers shortly after the next change in the beacon chain fork version.
|
||||
|
||||
Reference in New Issue
Block a user