mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-15 01:14:59 -05:00
feat: add reth init and reth import (#877)
Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
This commit is contained in:
@@ -7,7 +7,9 @@ use std::{fmt, str::FromStr};
|
||||
|
||||
// The chain spec module.
|
||||
mod spec;
|
||||
pub use spec::{ChainSpec, ChainSpecBuilder, ForkCondition, GOERLI, MAINNET, SEPOLIA};
|
||||
pub use spec::{
|
||||
AllGenesisFormats, ChainSpec, ChainSpecBuilder, ForkCondition, GOERLI, MAINNET, SEPOLIA,
|
||||
};
|
||||
|
||||
// The chain info module.
|
||||
mod info;
|
||||
|
||||
@@ -260,6 +260,37 @@ impl From<EthersGenesis> for ChainSpec {
|
||||
}
|
||||
}
|
||||
|
||||
/// A helper type for compatibility with geth's config
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum AllGenesisFormats {
|
||||
/// The geth genesis format
|
||||
Geth(EthersGenesis),
|
||||
/// The reth genesis format
|
||||
Reth(ChainSpec),
|
||||
}
|
||||
|
||||
impl From<EthersGenesis> for AllGenesisFormats {
|
||||
fn from(genesis: EthersGenesis) -> Self {
|
||||
Self::Geth(genesis)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ChainSpec> for AllGenesisFormats {
|
||||
fn from(genesis: ChainSpec) -> Self {
|
||||
Self::Reth(genesis)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AllGenesisFormats> for ChainSpec {
|
||||
fn from(genesis: AllGenesisFormats) -> Self {
|
||||
match genesis {
|
||||
AllGenesisFormats::Geth(genesis) => genesis.into(),
|
||||
AllGenesisFormats::Reth(genesis) => genesis,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A helper to build custom chain specs
|
||||
#[derive(Debug, Default)]
|
||||
pub struct ChainSpecBuilder {
|
||||
|
||||
@@ -38,7 +38,8 @@ pub use bits::H512;
|
||||
pub use block::{Block, BlockHashOrNumber, SealedBlock};
|
||||
pub use bloom::Bloom;
|
||||
pub use chain::{
|
||||
Chain, ChainInfo, ChainSpec, ChainSpecBuilder, ForkCondition, GOERLI, MAINNET, SEPOLIA,
|
||||
AllGenesisFormats, Chain, ChainInfo, ChainSpec, ChainSpecBuilder, ForkCondition, GOERLI,
|
||||
MAINNET, SEPOLIA,
|
||||
};
|
||||
pub use constants::{
|
||||
EMPTY_OMMER_ROOT, GOERLI_GENESIS, KECCAK_EMPTY, MAINNET_GENESIS, SEPOLIA_GENESIS,
|
||||
|
||||
Reference in New Issue
Block a user