kona_interop/
replacement.rs

1//! Contains the block replacement type.Add commentMore actions
2
3use alloy_primitives::B256;
4use derive_more::Display;
5use kona_protocol::BlockInfo;
6
7/// Represents a [`BlockReplacement`] event where one block replaces another.
8#[derive(Debug, Clone, Copy, Display, PartialEq, Eq)]
9#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
11#[display("replacement: {replacement}, invalidated: {invalidated}")]
12pub struct BlockReplacement<T = BlockInfo> {
13    /// The block that replaces the invalidated block
14    pub replacement: T,
15    /// Hash of the block being invalidated and replaced
16    pub invalidated: B256,
17}
18
19impl<T> BlockReplacement<T> {
20    /// Creates a new [`BlockReplacement`].
21    pub const fn new(replacement: T, invalidated: B256) -> Self {
22        Self { replacement, invalidated }
23    }
24}