Enum reth_ethereum_forks::ForkCondition

source ·
pub enum ForkCondition {
    Block(BlockNumber),
    TTD {
        fork_block: Option<BlockNumber>,
        total_difficulty: U256,
    },
    Timestamp(u64),
    Never,
}
Expand description

The condition at which a fork is activated.

Variants§

§

Block(BlockNumber)

The fork is activated after a certain block.

§

TTD

The fork is activated after a total difficulty has been reached.

Fields

§fork_block: Option<BlockNumber>

The block number at which TTD is reached, if it is known.

This should NOT be set unless you want this block advertised as EIP-2124 FORK_NEXT. This is currently only the case for Sepolia and Holesky.

§total_difficulty: U256

The total difficulty after which the fork is activated.

§

Timestamp(u64)

The fork is activated after a specific timestamp.

§

Never

The fork is never activated

Implementations§

source§

impl ForkCondition

source

pub const fn is_timestamp(&self) -> bool

Returns true if the fork condition is timestamp based.

source

pub const fn active_at_block(&self, current_block: BlockNumber) -> bool

Checks whether the fork condition is satisfied at the given block.

For TTD conditions, this will only return true if the activation block is already known.

For timestamp conditions, this will always return false.

source

pub const fn transitions_at_block(&self, current_block: BlockNumber) -> bool

Checks if the given block is the first block that satisfies the fork condition.

This will return false for any condition that is not block based.

source

pub fn active_at_ttd(&self, ttd: U256, difficulty: U256) -> bool

Checks whether the fork condition is satisfied at the given total difficulty and difficulty of a current block.

The fork is considered active if the previous total difficulty is above the threshold. To achieve that, we subtract the passed difficulty from the current block’s total difficulty, and check if it’s above the Fork Condition’s total difficulty (here: 58_750_000_000_000_000_000_000)

This will return false for any condition that is not TTD-based.

source

pub const fn active_at_timestamp(&self, timestamp: u64) -> bool

Checks whether the fork condition is satisfied at the given timestamp.

This will return false for any condition that is not timestamp-based.

source

pub const fn transitions_at_timestamp( &self, timestamp: u64, parent_timestamp: u64, ) -> bool

Checks if the given block is the first block that satisfies the fork condition.

This will return false for any condition that is not timestamp based.

source

pub fn active_at_head(&self, head: &Head) -> bool

Checks whether the fork condition is satisfied at the given head block.

This will return true if:

  • The condition is satisfied by the block number;
  • The condition is satisfied by the timestamp;
  • or the condition is satisfied by the total difficulty
source

pub const fn ttd(&self) -> Option<U256>

Get the total terminal difficulty for this fork condition.

Returns None for fork conditions that are not TTD based.

source

pub const fn as_timestamp(&self) -> Option<u64>

Returns the timestamp of the fork condition, if it is timestamp based.

Trait Implementations§

source§

impl Clone for ForkCondition

source§

fn clone(&self) -> ForkCondition

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ForkCondition

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ForkCondition

source§

fn default() -> ForkCondition

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for ForkCondition

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for ForkCondition

source§

fn eq(&self, other: &ForkCondition) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for ForkCondition

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for ForkCondition

source§

impl Eq for ForkCondition

source§

impl StructuralPartialEq for ForkCondition

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dst. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 48 bytes

Size for each variant:

  • Block: 16 bytes
  • TTD: 48 bytes
  • Timestamp: 16 bytes
  • Never: 0 bytes