pub struct ChainSpec<'a> { /* private fields */ }Expand description
Explicit chain rules used to select fork validation context.
Implementations§
Source§impl<'a> ChainSpec<'a>
impl<'a> ChainSpec<'a>
Sourcepub const fn new(chain_id: ChainId, forks: &'a [ForkSpec]) -> Self
pub const fn new(chain_id: ChainId, forks: &'a [ForkSpec]) -> Self
Creates a chain spec from caller-reviewed static fork entries.
This constructor is intentionally const for hand-audited static
tables. Use Self::try_new when entries come from dynamic config,
generated data, or any source that is not reviewed in code. Selection
methods still reject duplicate, unordered, or wrong-chain entries before
returning fork context.
Sourcepub fn try_new(
chain_id: ChainId,
forks: &'a [ForkSpec],
) -> Result<Self, ForkError>
pub fn try_new( chain_id: ChainId, forks: &'a [ForkSpec], ) -> Result<Self, ForkError>
Creates a chain spec after validating ordering, uniqueness, and chain ID.
Sourcepub fn fork_spec(self, hardfork: Hardfork) -> Result<ForkSpec, ForkError>
pub fn fork_spec(self, hardfork: Hardfork) -> Result<ForkSpec, ForkError>
Returns the spec for a hardfork admitted by this chain spec.
Sourcepub fn validation_context(
self,
hardfork: Hardfork,
block_number: BlockNumber,
timestamp: UnixTimestamp,
) -> Result<ValidationContext, ForkError>
pub fn validation_context( self, hardfork: Hardfork, block_number: BlockNumber, timestamp: UnixTimestamp, ) -> Result<ValidationContext, ForkError>
Builds an explicit validation context for an active hardfork.
Sourcepub fn active_fork(
self,
block_number: BlockNumber,
timestamp: UnixTimestamp,
) -> Result<ForkSpec, ForkError>
pub fn active_fork( self, block_number: BlockNumber, timestamp: UnixTimestamp, ) -> Result<ForkSpec, ForkError>
Returns the highest active hardfork in this chain spec.
Trait Implementations§
impl<'a> Copy for ChainSpec<'a>
impl<'a> Eq for ChainSpec<'a>
Source§impl<'a> PartialEq for ChainSpec<'a>
impl<'a> PartialEq for ChainSpec<'a>
impl<'a> StructuralPartialEq for ChainSpec<'a>
Auto Trait Implementations§
impl<'a> Freeze for ChainSpec<'a>
impl<'a> RefUnwindSafe for ChainSpec<'a>
impl<'a> Send for ChainSpec<'a>
impl<'a> Sync for ChainSpec<'a>
impl<'a> Unpin for ChainSpec<'a>
impl<'a> UnsafeUnpin for ChainSpec<'a>
impl<'a> UnwindSafe for ChainSpec<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more