chore(clippy): enable if_then_some_else_none lint (#11679)

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Delweng
2024-10-14 23:45:26 +08:00
committed by GitHub
parent 523bfb9c81
commit f684dd4c4c
22 changed files with 87 additions and 135 deletions

View File

@ -542,18 +542,18 @@ impl<TX: DbTx, Spec: Send + Sync> DatabaseProvider<TX, Spec> {
// even if empty
let withdrawals =
if self.chain_spec.is_shanghai_active_at_timestamp(header_ref.timestamp) {
Some(
withdrawals_cursor
.seek_exact(header_ref.number)?
.map(|(_, w)| w.withdrawals)
.unwrap_or_default(),
)
withdrawals_cursor
.seek_exact(header_ref.number)?
.map(|(_, w)| w.withdrawals)
.unwrap_or_default()
.into()
} else {
None
};
let requests =
if self.chain_spec.is_prague_active_at_timestamp(header_ref.timestamp) {
Some(requests_cursor.seek_exact(header_ref.number)?.unwrap_or_default().1)
(requests_cursor.seek_exact(header_ref.number)?.unwrap_or_default().1)
.into()
} else {
None
};

View File

@ -222,7 +222,7 @@ impl StaticFileProviderInner {
/// Creates a new [`StaticFileProviderInner`].
fn new(path: impl AsRef<Path>, access: StaticFileAccess) -> ProviderResult<Self> {
let _lock_file = if access.is_read_write() {
Some(StorageLock::try_acquire(path.as_ref())?)
StorageLock::try_acquire(path.as_ref())?.into()
} else {
None
};

View File

@ -289,16 +289,16 @@ impl StaticFileProviderRW {
//
// If that expected block start is 0, then it means that there's no actual block data, and
// there's no block data in static files.
let segment_max_block = match self.writer.user_header().block_range() {
Some(block_range) => Some(block_range.end()),
None => {
if self.writer.user_header().expected_block_start() > 0 {
Some(self.writer.user_header().expected_block_start() - 1)
} else {
None
}
}
};
let segment_max_block = self
.writer
.user_header()
.block_range()
.as_ref()
.map(|block_range| block_range.end())
.or_else(|| {
(self.writer.user_header().expected_block_start() > 0)
.then(|| self.writer.user_header().expected_block_start() - 1)
});
self.reader().update_index(self.writer.user_header().segment(), segment_max_block)
}

View File

@ -344,13 +344,8 @@ impl TransactionsProvider for MockEthProvider {
.values()
.flat_map(|block| &block.body.transactions)
.enumerate()
.filter_map(|(tx_number, tx)| {
if range.contains(&(tx_number as TxNumber)) {
Some(tx.clone().into())
} else {
None
}
})
.filter(|&(tx_number, _)| range.contains(&(tx_number as TxNumber)))
.map(|(_, tx)| tx.clone().into())
.collect();
Ok(transactions)
@ -366,11 +361,7 @@ impl TransactionsProvider for MockEthProvider {
.flat_map(|block| &block.body.transactions)
.enumerate()
.filter_map(|(tx_number, tx)| {
if range.contains(&(tx_number as TxNumber)) {
Some(tx.recover_signer()?)
} else {
None
}
range.contains(&(tx_number as TxNumber)).then(|| tx.recover_signer()).flatten()
})
.collect();