feat: replace once_cell with std (#11694)

Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
This commit is contained in:
Deil Urba
2024-10-15 09:21:01 +01:00
committed by GitHub
parent 2a86245649
commit 3ab1f9559e
19 changed files with 129 additions and 80 deletions

View File

@ -13,10 +13,14 @@ use alloy_primitives::{Bytes, TxHash};
use alloy_rlp::{Decodable, Encodable, Error as RlpError, Header};
use core::mem;
use derive_more::{AsRef, Deref};
use once_cell::sync::Lazy;
use once_cell as _;
#[cfg(not(feature = "std"))]
use once_cell::sync::Lazy as LazyLock;
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
use serde::{Deserialize, Serialize};
use signature::{decode_with_eip155_chain_id, with_eip155_parity};
#[cfg(feature = "std")]
use std::sync::LazyLock;
pub use error::{
InvalidTransactionError, TransactionConversionError, TryFromRecoveredTransactionError,
@ -72,8 +76,8 @@ pub type TxHashOrNumber = BlockHashOrNumber;
// Expected number of transactions where we can expect a speed-up by recovering the senders in
// parallel.
pub(crate) static PARALLEL_SENDER_RECOVERY_THRESHOLD: Lazy<usize> =
Lazy::new(|| match rayon::current_num_threads() {
pub(crate) static PARALLEL_SENDER_RECOVERY_THRESHOLD: LazyLock<usize> =
LazyLock::new(|| match rayon::current_num_threads() {
0..=1 => usize::MAX,
2..=8 => 10,
_ => 5,