Skip to content

Commit fda4f2c

Browse files
committed
Fix lints
1 parent 193061f commit fda4f2c

File tree

30 files changed

+58
-66
lines changed

30 files changed

+58
-66
lines changed

beacon_node/beacon_chain/src/attestation_verification.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,19 +1450,17 @@ where
14501450
return Err(Error::UnknownTargetRoot(target.root));
14511451
}
14521452

1453-
chain
1454-
.with_committee_cache(target.root, attestation_epoch, |committee_cache, _| {
1455-
let committees_per_slot = committee_cache.committees_per_slot();
1456-
1457-
Ok(committee_cache
1458-
.get_beacon_committees_at_slot(attestation.data().slot)
1459-
.map(|committees| map_fn((committees, committees_per_slot)))
1460-
.unwrap_or_else(|_| {
1461-
Err(Error::NoCommitteeForSlotAndIndex {
1462-
slot: attestation.data().slot,
1463-
index: attestation.committee_index().unwrap_or(0),
1464-
})
1465-
}))
1466-
})
1467-
.map_err(BeaconChainError::from)?
1453+
chain.with_committee_cache(target.root, attestation_epoch, |committee_cache, _| {
1454+
let committees_per_slot = committee_cache.committees_per_slot();
1455+
1456+
Ok(committee_cache
1457+
.get_beacon_committees_at_slot(attestation.data().slot)
1458+
.map(|committees| map_fn((committees, committees_per_slot)))
1459+
.unwrap_or_else(|_| {
1460+
Err(Error::NoCommitteeForSlotAndIndex {
1461+
slot: attestation.data().slot,
1462+
index: attestation.committee_index().unwrap_or(0),
1463+
})
1464+
}))
1465+
})?
14681466
}

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6505,9 +6505,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
65056505

65066506
/// Returns `true` if the given slot is prior to the `bellatrix_fork_epoch`.
65076507
pub fn slot_is_prior_to_bellatrix(&self, slot: Slot) -> bool {
6508-
self.spec.bellatrix_fork_epoch.map_or(true, |bellatrix| {
6509-
slot.epoch(T::EthSpec::slots_per_epoch()) < bellatrix
6510-
})
6508+
self.spec
6509+
.bellatrix_fork_epoch
6510+
.is_none_or(|bellatrix| slot.epoch(T::EthSpec::slots_per_epoch()) < bellatrix)
65116511
}
65126512

65136513
/// Returns the value of `execution_optimistic` for `block`.

beacon_node/beacon_chain/src/block_times_cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl BlockTimesCache {
173173
if block_times
174174
.timestamps
175175
.all_blobs_observed
176-
.map_or(true, |prev| timestamp > prev)
176+
.is_none_or(|prev| timestamp > prev)
177177
{
178178
block_times.timestamps.all_blobs_observed = Some(timestamp);
179179
}
@@ -195,7 +195,7 @@ impl BlockTimesCache {
195195
.entry(block_root)
196196
.or_insert_with(|| BlockTimesCacheValue::new(slot));
197197
let existing_timestamp = field(&mut block_times.timestamps);
198-
if existing_timestamp.map_or(true, |prev| timestamp < prev) {
198+
if existing_timestamp.is_none_or(|prev| timestamp < prev) {
199199
*existing_timestamp = Some(timestamp);
200200
}
201201
}

beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ impl<E: EthSpec> PendingComponents<E> {
297297
.map(|b| b.map(|b| b.to_blob()))
298298
.take(num_blobs_expected)
299299
.collect::<Option<Vec<_>>>()
300-
.map(Into::into)
301300
else {
302301
return Err(AvailabilityCheckError::Unexpected);
303302
};

beacon_node/beacon_chain/src/shuffling_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl ShufflingCache {
138138
.get(&key)
139139
// Replace the committee if it's not present or if it's a promise. A bird in the hand is
140140
// worth two in the promise-bush!
141-
.map_or(true, CacheItem::is_promise)
141+
.is_none_or(CacheItem::is_promise)
142142
{
143143
self.insert_cache_item(
144144
key,

beacon_node/beacon_chain/src/validator_monitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ impl<E: EthSpec> ValidatorMonitor<E> {
628628
// the proposer shuffling cache lock when there are lots of missed blocks.
629629
if proposers_per_epoch
630630
.as_ref()
631-
.map_or(true, |(_, cached_epoch)| *cached_epoch != slot_epoch)
631+
.is_none_or(|(_, cached_epoch)| *cached_epoch != slot_epoch)
632632
{
633633
proposers_per_epoch = self
634634
.get_proposers_by_epoch_from_cache(

beacon_node/client/src/notifier.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
187187
let is_backfilling = matches!(current_sync_state, SyncState::BackFillSyncing { .. });
188188
if is_backfilling
189189
&& last_backfill_log_slot
190-
.map_or(true, |slot| slot + BACKFILL_LOG_INTERVAL <= current_slot)
190+
.is_none_or(|slot| slot + BACKFILL_LOG_INTERVAL <= current_slot)
191191
{
192192
last_backfill_log_slot = Some(current_slot);
193193

beacon_node/execution_layer/src/test_utils/execution_block_generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
448448
if self
449449
.head_block
450450
.as_ref()
451-
.map_or(true, |head| head.block_hash() == last_block_hash)
451+
.is_none_or(|head| head.block_hash() == last_block_hash)
452452
{
453453
self.head_block = Some(block.clone());
454454
}

beacon_node/genesis/src/eth1_genesis_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl Eth1GenesisService {
263263
// again later.
264264
if eth1_service
265265
.highest_safe_block()
266-
.map_or(true, |n| block.number > n)
266+
.is_none_or(|n| block.number > n)
267267
{
268268
continue;
269269
}

beacon_node/http_api/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,10 +1939,10 @@ pub fn serve<T: BeaconChainTypes>(
19391939
query: api_types::AttestationPoolQuery| {
19401940
task_spawner.blocking_response_task(Priority::P1, move || {
19411941
let query_filter = |data: &AttestationData| {
1942-
query.slot.map_or(true, |slot| slot == data.slot)
1942+
query.slot.is_none_or(|slot| slot == data.slot)
19431943
&& query
19441944
.committee_index
1945-
.map_or(true, |index| index == data.index)
1945+
.is_none_or(|index| index == data.index)
19461946
};
19471947

19481948
let mut attestations = chain.op_pool.get_filtered_attestations(query_filter);
@@ -3159,11 +3159,11 @@ pub fn serve<T: BeaconChainTypes>(
31593159
peer_info.connection_status(),
31603160
);
31613161

3162-
let state_matches = query.state.as_ref().map_or(true, |states| {
3162+
let state_matches = query.state.as_ref().is_none_or(|states| {
31633163
states.iter().any(|state_param| *state_param == state)
31643164
});
31653165
let direction_matches =
3166-
query.direction.as_ref().map_or(true, |directions| {
3166+
query.direction.as_ref().is_none_or(|directions| {
31673167
directions.iter().any(|dir_param| *dir_param == direction)
31683168
});
31693169

0 commit comments

Comments
 (0)