feat: add Display for BeaconConsensusEngineEvent (#11055)

This commit is contained in:
Dan Cline
2024-09-19 19:52:36 -04:00
committed by GitHub
parent f9eb20d0a0
commit c9057d75c1

View File

@ -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 {