Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn make_genesis_header(genesis: &Genesis, hardforks: &ChainHardforks) -> Hea
let base_fee_per_gas = hardforks
.fork(EthereumHardfork::London)
.active_at_block(0)
.then(|| genesis.base_fee_per_gas.map(|fee| fee as u64).unwrap_or(INITIAL_BASE_FEE));
.then(|| genesis.base_fee_per_gas.map_or(INITIAL_BASE_FEE, |fee| fee as u64));

// If shanghai is activated, initialize the header with an empty withdrawals hash, and
// empty withdrawals list.
Expand Down Expand Up @@ -505,7 +505,7 @@ impl<H: BlockHeader> ChainSpec<H> {
pub fn initial_base_fee(&self) -> Option<u64> {
// If the base fee is set in the genesis block, we use that instead of the default.
let genesis_base_fee =
self.genesis.base_fee_per_gas.map(|fee| fee as u64).unwrap_or(INITIAL_BASE_FEE);
self.genesis.base_fee_per_gas.map_or(INITIAL_BASE_FEE, |fee| fee as u64);

// If London is activated at genesis, we set the initial base fee as per EIP-1559.
self.hardforks.fork(EthereumHardfork::London).active_at_block(0).then_some(genesis_base_fee)
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/tree/src/tree/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl EngineApiMetrics {
// Use metered to execute and track timing/gas metrics
let (mut db, result) = self.metered(|| {
let res = f();
let gas_used = res.as_ref().map(|r| r.1.gas_used).unwrap_or(0);
let gas_used = res.as_ref().map_or(0, |r| r.1.gas_used);
(gas_used, res)
})?;

Expand Down
4 changes: 2 additions & 2 deletions crates/storage/provider/src/providers/state/historical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,13 @@ impl LowestAvailableBlocks {
/// Check if account history is available at the provided block number, i.e. lowest available
/// block number for account history is less than or equal to the provided block number.
pub fn is_account_history_available(&self, at: BlockNumber) -> bool {
self.account_history_block_number.map(|block_number| block_number <= at).unwrap_or(true)
self.account_history_block_number.is_none_or(|block_number| block_number <= at)
}

/// Check if storage history is available at the provided block number, i.e. lowest available
/// block number for storage history is less than or equal to the provided block number.
pub fn is_storage_history_available(&self, at: BlockNumber) -> bool {
self.storage_history_block_number.map(|block_number| block_number <= at).unwrap_or(true)
self.storage_history_block_number.is_none_or(|block_number| block_number <= at)
}
}

Expand Down
5 changes: 2 additions & 3 deletions crates/storage/provider/src/providers/static_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,8 @@ mod tests {

/// Returns the number of files in the provided path, excluding ".lock" files.
fn count_files_without_lockfile(path: impl AsRef<Path>) -> eyre::Result<usize> {
let is_lockfile = |entry: &fs::DirEntry| {
entry.path().file_name().map(|name| name == "lock").unwrap_or(false)
};
let is_lockfile =
|entry: &fs::DirEntry| entry.path().file_name().is_some_and(|name| name == "lock");
let count = fs::read_dir(path)?
.filter_map(|entry| entry.ok())
.filter(|entry| !is_lockfile(entry))
Expand Down
2 changes: 1 addition & 1 deletion crates/tracing/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl LogFormat {
file_writer: Option<NonBlocking>,
) -> BoxedLayer<Registry> {
let ansi = if let Some(color) = color {
std::env::var("RUST_LOG_STYLE").map(|val| val != "never").unwrap_or(color != "never")
std::env::var("RUST_LOG_STYLE").ok().map_or(color != "never", |val| val != "never")
} else {
false
};
Expand Down
4 changes: 2 additions & 2 deletions crates/trie/common/src/proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl MultiProof {

// Retrieve proofs for requested storage slots.
let storage_multiproof = self.storages.get(&hashed_address);
let storage_root = storage_multiproof.map(|m| m.root).unwrap_or(EMPTY_ROOT_HASH);
let storage_root = storage_multiproof.map_or(EMPTY_ROOT_HASH, |m| m.root);
let mut storage_proofs = Vec::with_capacity(slots.len());
for slot in slots {
let proof = if let Some(multiproof) = &storage_multiproof {
Expand Down Expand Up @@ -378,7 +378,7 @@ impl DecodedMultiProof {

// Retrieve proofs for requested storage slots.
let storage_multiproof = self.storages.get(&hashed_address);
let storage_root = storage_multiproof.map(|m| m.root).unwrap_or(EMPTY_ROOT_HASH);
let storage_root = storage_multiproof.map_or(EMPTY_ROOT_HASH, |m| m.root);
let mut storage_proofs = Vec::with_capacity(slots.len());
for slot in slots {
let proof = if let Some(multiproof) = &storage_multiproof {
Expand Down
Loading