Skip to content

Commit

Permalink
feat: add Display for BeaconConsensusEngineEvent (#11055)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected authored Sep 19, 2024
1 parent f9eb20d commit c9057d7
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion crates/consensus/beacon/src/engine/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ use crate::engine::forkchoice::ForkchoiceStatus;
use alloy_primitives::B256;
use reth_primitives::{SealedBlock, SealedHeader};
use reth_rpc_types::engine::ForkchoiceState;
use std::{sync::Arc, time::Duration};
use std::{
fmt::{Display, Formatter, Result},
sync::Arc,
time::Duration,
};

/// Events emitted by [`crate::BeaconConsensusEngine`].
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -30,6 +34,28 @@ impl BeaconConsensusEngineEvent {
}
}

impl Display for BeaconConsensusEngineEvent {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
match self {
Self::ForkchoiceUpdated(state, status) => {
write!(f, "ForkchoiceUpdated({state:?}, {status:?})")
}
Self::ForkBlockAdded(block, duration) => {
write!(f, "ForkBlockAdded({:?}, {duration:?})", block.num_hash())
}
Self::CanonicalBlockAdded(block, duration) => {
write!(f, "CanonicalBlockAdded({:?}, {duration:?})", block.num_hash())
}
Self::CanonicalChainCommitted(block, duration) => {
write!(f, "CanonicalChainCommitted({:?}, {duration:?})", block.num_hash())
}
Self::LiveSyncProgress(progress) => {
write!(f, "LiveSyncProgress({progress:?})")
}
}
}
}

/// Progress of the consensus engine during live sync.
#[derive(Clone, Debug)]
pub enum ConsensusEngineLiveSyncProgress {
Expand Down

0 comments on commit c9057d7

Please sign in to comment.