mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: add Hardfork::boxed (#13737)
This commit is contained in:
@ -8,7 +8,7 @@ use once_cell::sync::Lazy as LazyLock;
|
||||
#[cfg(feature = "std")]
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use crate::{ChainHardforks, EthereumHardfork, ForkCondition};
|
||||
use crate::{ChainHardforks, EthereumHardfork, ForkCondition, Hardfork};
|
||||
|
||||
/// Dev hardforks
|
||||
pub static DEV_HARDFORKS: LazyLock<ChainHardforks> = LazyLock::new(|| {
|
||||
|
||||
@ -17,11 +17,6 @@ macro_rules! hardfork {
|
||||
$( $enum::$variant => stringify!($variant), )*
|
||||
}
|
||||
}
|
||||
|
||||
/// Boxes `self` and returns it as `Box<dyn Hardfork>`.
|
||||
pub fn boxed(self) -> Box<dyn Hardfork> {
|
||||
Box::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for $enum {
|
||||
|
||||
@ -6,6 +6,7 @@ pub use ethereum::EthereumHardfork;
|
||||
mod dev;
|
||||
pub use dev::DEV_HARDFORKS;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use core::{
|
||||
any::Any,
|
||||
hash::{Hash, Hasher},
|
||||
@ -17,6 +18,11 @@ use dyn_clone::DynClone;
|
||||
pub trait Hardfork: Any + DynClone + Send + Sync + 'static {
|
||||
/// Fork name.
|
||||
fn name(&self) -> &'static str;
|
||||
|
||||
/// Returns boxed value.
|
||||
fn boxed(&self) -> Box<dyn Hardfork + '_> {
|
||||
Box::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
dyn_clone::clone_trait_object!(Hardfork);
|
||||
|
||||
@ -5,7 +5,7 @@ use alloc::{sync::Arc, vec};
|
||||
use alloy_chains::Chain;
|
||||
use alloy_primitives::{b256, U256};
|
||||
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
|
||||
use reth_ethereum_forks::EthereumHardfork;
|
||||
use reth_ethereum_forks::{EthereumHardfork, Hardfork};
|
||||
use reth_optimism_forks::OpHardfork;
|
||||
|
||||
use crate::{LazyLock, OpChainSpec};
|
||||
|
||||
@ -4,7 +4,7 @@ use alloc::{sync::Arc, vec};
|
||||
|
||||
use alloy_chains::Chain;
|
||||
use alloy_primitives::{b256, U256};
|
||||
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
|
||||
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec, Hardfork};
|
||||
use reth_ethereum_forks::EthereumHardfork;
|
||||
use reth_optimism_forks::OpHardfork;
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ use crate::{LazyLock, OpChainSpec};
|
||||
use alloc::{sync::Arc, vec};
|
||||
use alloy_chains::Chain;
|
||||
use alloy_primitives::{b256, U256};
|
||||
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
|
||||
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec, Hardfork};
|
||||
use reth_ethereum_forks::EthereumHardfork;
|
||||
use reth_optimism_forks::OpHardfork;
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ use crate::{LazyLock, OpChainSpec};
|
||||
use alloc::{sync::Arc, vec};
|
||||
use alloy_chains::{Chain, NamedChain};
|
||||
use alloy_primitives::{b256, U256};
|
||||
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
|
||||
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec, Hardfork};
|
||||
use reth_ethereum_forks::EthereumHardfork;
|
||||
use reth_optimism_forks::OpHardfork;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use alloc::vec;
|
||||
use alloy_primitives::U256;
|
||||
use reth_ethereum_forks::{ChainHardforks, EthereumHardfork, ForkCondition};
|
||||
use reth_ethereum_forks::{ChainHardforks, EthereumHardfork, ForkCondition, Hardfork};
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use once_cell::sync::Lazy as LazyLock;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//! Hard forks of optimism protocol.
|
||||
|
||||
use alloc::{boxed::Box, format, string::String, vec};
|
||||
use alloc::{format, string::String, vec};
|
||||
use core::{
|
||||
any::Any,
|
||||
fmt::{self, Display, Formatter},
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
use alloy_primitives::{b256, B256};
|
||||
use reth_chainspec::{
|
||||
once_cell_set, BaseFeeParams, Chain, ChainHardforks, ChainSpec, EthereumHardfork, ForkCondition,
|
||||
once_cell_set, BaseFeeParams, Chain, ChainHardforks, ChainSpec, EthereumHardfork,
|
||||
ForkCondition, Hardfork,
|
||||
};
|
||||
use reth_network_peers::NodeRecord;
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
use alloy_primitives::{b256, B256};
|
||||
use reth_chainspec::{
|
||||
once_cell_set, BaseFeeParams, Chain, ChainHardforks, ChainSpec, EthereumHardfork, ForkCondition,
|
||||
once_cell_set, BaseFeeParams, Chain, ChainHardforks, ChainSpec, EthereumHardfork,
|
||||
ForkCondition, Hardfork,
|
||||
};
|
||||
use reth_discv4::NodeRecord;
|
||||
use reth_primitives::Head;
|
||||
|
||||
Reference in New Issue
Block a user