Repository navigation
Expand file tree
/
Copy pathapi.rs
More file actions
121 lines (92 loc) · 3.25 KB
/
Copy pathapi.rs
File metadata and controls
121 lines (92 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
use crate::{ChainSpec, DepositContract};
use alloc::{boxed::Box, vec::Vec};
use alloy_chains::Chain;
use alloy_eips::eip1559::BaseFeeParams;
use alloy_genesis::Genesis;
use alloy_primitives::B256;
use core::fmt::{Debug, Display};
use reth_network_peers::NodeRecord;
use reth_primitives_traits::Header;
/// Trait representing type configuring a chain spec.
#[auto_impl::auto_impl(&, Arc)]
pub trait EthChainSpec: Send + Sync + Unpin + Debug {
// todo: make chain spec type generic over hardfork
//type Hardfork: Clone + Copy + 'static;
/// Returns the [`Chain`] object this spec targets.
fn chain(&self) -> Chain;
/// Returns the chain id number
fn chain_id(&self) -> u64 {
self.chain().id()
}
/// Get the [`BaseFeeParams`] for the chain at the given block.
fn base_fee_params_at_block(&self, block_number: u64) -> BaseFeeParams;
/// Get the [`BaseFeeParams`] for the chain at the given timestamp.
fn base_fee_params_at_timestamp(&self, timestamp: u64) -> BaseFeeParams;
/// Returns the deposit contract data for the chain, if it's present
fn deposit_contract(&self) -> Option<&DepositContract>;
/// The genesis hash.
fn genesis_hash(&self) -> B256;
/// The delete limit for pruner, per run.
fn prune_delete_limit(&self) -> usize;
/// Returns a string representation of the hardforks.
fn display_hardforks(&self) -> Box<dyn Display>;
/// The genesis header.
fn genesis_header(&self) -> &Header;
/// The genesis block specification.
fn genesis(&self) -> &Genesis;
/// The block gas limit.
fn max_gas_limit(&self) -> u64;
/// The bootnodes for the chain, if any.
fn bootnodes(&self) -> Option<Vec<NodeRecord>>;
/// Returns `true` if this chain contains Optimism configuration.
fn is_optimism(&self) -> bool {
self.chain().is_optimism()
}
/// Returns `true` if this chain contains Ethereum configuration.
fn is_ethereum(&self) -> bool {
self.chain().is_ethereum()
}
/// Returns `true` if this chain contains Binance Smart Chain configuration.
fn is_bsc(&self) -> bool;
}
impl EthChainSpec for ChainSpec {
fn chain(&self) -> Chain {
self.chain
}
fn base_fee_params_at_block(&self, block_number: u64) -> BaseFeeParams {
self.base_fee_params_at_block(block_number)
}
fn base_fee_params_at_timestamp(&self, timestamp: u64) -> BaseFeeParams {
self.base_fee_params_at_timestamp(timestamp)
}
fn deposit_contract(&self) -> Option<&DepositContract> {
self.deposit_contract.as_ref()
}
fn genesis_hash(&self) -> B256 {
self.genesis_hash()
}
fn prune_delete_limit(&self) -> usize {
self.prune_delete_limit
}
fn display_hardforks(&self) -> Box<dyn Display> {
Box::new(Self::display_hardforks(self))
}
fn genesis_header(&self) -> &Header {
self.genesis_header()
}
fn genesis(&self) -> &Genesis {
self.genesis()
}
fn max_gas_limit(&self) -> u64 {
self.max_gas_limit
}
fn bootnodes(&self) -> Option<Vec<NodeRecord>> {
self.bootnodes()
}
fn is_optimism(&self) -> bool {
self.chain.is_optimism()
}
fn is_bsc(&self) -> bool {
Self::is_bsc(self)
}
}