mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Rust 1.85 lints (#7019)
N/A 2 changes: 1. Replace Option::map_or(true, ...) with is_none_or(...) 2. Remove unnecessary `Into::into` blocks where the type conversion is apparent from the types
This commit is contained in:
@@ -767,7 +767,7 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
|
||||
// Disabling an already disabled validator *with no other changes* is a
|
||||
// no-op.
|
||||
(Some(false), None)
|
||||
if body.enabled.map_or(true, |enabled| !enabled)
|
||||
if body.enabled.is_none_or(|enabled| !enabled)
|
||||
&& body.gas_limit.is_none()
|
||||
&& body.builder_boost_factor.is_none()
|
||||
&& body.builder_proposals.is_none()
|
||||
|
||||
@@ -1113,7 +1113,7 @@ fn max_or<T: Copy + Ord>(opt_x: Option<T>, y: T) -> T {
|
||||
///
|
||||
/// If prev is `None` and `new` is `Some` then `true` is returned.
|
||||
fn monotonic<T: PartialOrd>(new: Option<T>, prev: Option<T>) -> bool {
|
||||
new.is_some_and(|new_val| prev.map_or(true, |prev_val| new_val >= prev_val))
|
||||
new.is_some_and(|new_val| prev.is_none_or(|prev_val| new_val >= prev_val))
|
||||
}
|
||||
|
||||
/// The result of importing a single entry from an interchange file.
|
||||
|
||||
@@ -843,10 +843,10 @@ async fn poll_beacon_attesters_for_epoch<T: SlotClock + 'static, E: EthSpec>(
|
||||
local_pubkeys
|
||||
.iter()
|
||||
.filter(|pubkey| {
|
||||
attesters.get(pubkey).map_or(true, |duties| {
|
||||
attesters.get(pubkey).is_none_or(|duties| {
|
||||
duties
|
||||
.get(&epoch)
|
||||
.map_or(true, |(prior, _)| *prior != dependent_root)
|
||||
.is_none_or(|(prior, _)| *prior != dependent_root)
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
@@ -974,7 +974,7 @@ fn get_uninitialized_validators<T: SlotClock + 'static, E: EthSpec>(
|
||||
.filter(|pubkey| {
|
||||
attesters
|
||||
.get(pubkey)
|
||||
.map_or(true, |duties| !duties.contains_key(epoch))
|
||||
.is_none_or(|duties| !duties.contains_key(epoch))
|
||||
})
|
||||
.filter_map(|pubkey| duties_service.validator_store.validator_index(pubkey))
|
||||
.collect::<Vec<_>>()
|
||||
|
||||
@@ -297,7 +297,7 @@ pub async fn poll_sync_committee_duties<T: SlotClock + 'static, E: EthSpec>(
|
||||
// If the Altair fork is yet to be activated, do not attempt to poll for duties.
|
||||
if spec
|
||||
.altair_fork_epoch
|
||||
.map_or(true, |altair_epoch| current_epoch < altair_epoch)
|
||||
.is_none_or(|altair_epoch| current_epoch < altair_epoch)
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
@@ -474,7 +474,7 @@ pub async fn poll_sync_committee_duties_for_period<T: SlotClock + 'static, E: Et
|
||||
.get_mut(&duty.validator_index)
|
||||
.ok_or(Error::SyncDutiesNotFound(duty.validator_index))?;
|
||||
|
||||
let updated = validator_duties.as_ref().map_or(true, |existing_duties| {
|
||||
let updated = validator_duties.as_ref().is_none_or(|existing_duties| {
|
||||
let updated_due_to_reorg = existing_duties.duty.validator_sync_committee_indices
|
||||
!= duty.validator_sync_committee_indices;
|
||||
if updated_due_to_reorg {
|
||||
|
||||
@@ -185,7 +185,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
let mut validator_def = ValidatorDefinition::new_keystore_with_password(
|
||||
voting_keystore_path,
|
||||
password_storage,
|
||||
graffiti.map(Into::into),
|
||||
graffiti,
|
||||
suggested_fee_recipient,
|
||||
gas_limit,
|
||||
builder_proposals,
|
||||
@@ -327,7 +327,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
.as_ref()
|
||||
// If there's no doppelganger service then we assume it is purposefully disabled and
|
||||
// declare that all keys are safe with regard to it.
|
||||
.map_or(true, |doppelganger_service| {
|
||||
.is_none_or(|doppelganger_service| {
|
||||
doppelganger_service
|
||||
.validator_status(validator_pubkey)
|
||||
.only_safe()
|
||||
|
||||
Reference in New Issue
Block a user