refactor: move LazyLock and OnlyLock exports to primitives traits (#13682)

This commit is contained in:
Léa Narzis
2025-01-07 15:28:57 +01:00
committed by GitHub
parent 4d12dcda7c
commit 0d5c0d2701
10 changed files with 27 additions and 23 deletions

View File

@ -26,7 +26,6 @@ alloy-consensus.workspace = true
# misc
auto_impl.workspace = true
once_cell.workspace = true
serde_json.workspace = true
derive_more.workspace = true
@ -47,7 +46,6 @@ std = [
"alloy-trie/std",
"reth-primitives-traits/std",
"alloy-consensus/std",
"once_cell/std",
"alloy-rlp/std",
"reth-ethereum-forks/std",
"derive_more/std",

View File

@ -11,12 +11,6 @@
extern crate alloc;
use once_cell as _;
#[cfg(not(feature = "std"))]
pub(crate) use once_cell::sync::{Lazy as LazyLock, OnceCell as OnceLock};
#[cfg(feature = "std")]
pub(crate) use std::sync::{LazyLock, OnceLock};
/// Chain specific constants
pub(crate) mod constants;
pub use constants::MIN_TRANSACTION_GAS;
@ -40,6 +34,8 @@ pub use spec::{
DepositContract, ForkBaseFeeParams, DEV, HOLESKY, MAINNET, SEPOLIA,
};
use reth_primitives_traits::sync::OnceLock;
/// Simple utility to create a thread-safe sync cell with a value set.
pub fn once_cell_set<T>(value: T) -> OnceLock<T> {
let once = OnceLock::new();

View File

@ -1,6 +1,6 @@
pub use alloy_eips::eip1559::BaseFeeParams;
use crate::{constants::MAINNET_DEPOSIT_CONTRACT, once_cell_set, EthChainSpec, LazyLock, OnceLock};
use crate::{constants::MAINNET_DEPOSIT_CONTRACT, once_cell_set, EthChainSpec};
use alloc::{boxed::Box, collections::BTreeMap, string::String, sync::Arc, vec::Vec};
use alloy_chains::{Chain, NamedChain};
use alloy_consensus::{
@ -28,7 +28,10 @@ use reth_network_peers::{
base_nodes, base_testnet_nodes, holesky_nodes, mainnet_nodes, op_nodes, op_testnet_nodes,
sepolia_nodes, NodeRecord,
};
use reth_primitives_traits::SealedHeader;
use reth_primitives_traits::{
sync::{LazyLock, OnceLock},
SealedHeader,
};
/// The Ethereum mainnet spec
pub static MAINNET: LazyLock<Arc<ChainSpec>> = LazyLock::new(|| {