From c9057d75c1450827044fa953752ba9dcd5f99b32 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Thu, 19 Sep 2024 19:52:36 -0400 Subject: [PATCH] feat: add Display for BeaconConsensusEngineEvent (#11055) --- crates/consensus/beacon/src/engine/event.rs | 28 ++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/crates/consensus/beacon/src/engine/event.rs b/crates/consensus/beacon/src/engine/event.rs index 994cda060c61..d617ee4f23c4 100644 --- a/crates/consensus/beacon/src/engine/event.rs +++ b/crates/consensus/beacon/src/engine/event.rs @@ -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)] @@ -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 {