Skip to main content

tempo_hardfork

Macro tempo_hardfork 

Source
macro_rules! tempo_hardfork {
    (
        $(#[$enum_meta:meta])*
        TempoHardfork {
            $(#[$genesis_meta:meta])* Genesis,
            $( $(#[$meta:meta])* $variant:ident ),* $(,)?
        }
    ) => { ... };
}
Expand description

Single-source hardfork definition macro. Append a new variant and everything else is generated:

  • Defines the TempoHardfork enum via [hardfork!] (including Display, FromStr, Hardfork trait impl, and VARIANTS const)
  • Generates is_<fork>() inherent methods on TempoHardfork — returns true when *self >= Self::<Fork>
  • Generates the TempoHardforks trait with:
    • tempo_fork_activation() (required — the only method implementors provide)
    • tempo_hardfork_at() — walks VARIANTS in reverse to find the latest active fork
    • is_<fork>_active_at_timestamp() — per-fork convenience helpers
    • general_gas_limit_at() — gas limit lookup by timestamp
  • Generates a #[cfg(test)] mod tests with activation, naming, trait, and serde tests

Genesis (first variant) is treated as the baseline and does not get is_*() methods. All subsequent variants are considered post-Genesis hardforks.