chore: add display to FromEngine and other messages (#10986)

This commit is contained in:
Matthias Seitz
2024-09-18 15:11:38 +02:00
committed by GitHub
parent 5cd603d346
commit 94c15c0074
3 changed files with 54 additions and 1 deletions

View File

@ -8,6 +8,7 @@ use reth_rpc_types::engine::{
ForkchoiceUpdateError, ForkchoiceUpdated, PayloadId, PayloadStatus, PayloadStatusEnum,
};
use std::{
fmt::Display,
future::Future,
pin::Pin,
task::{ready, Context, Poll},
@ -160,3 +161,31 @@ pub enum BeaconEngineMessage<Engine: EngineTypes> {
/// Message with exchanged transition configuration.
TransitionConfigurationExchanged,
}
impl<Engine: EngineTypes> Display for BeaconEngineMessage<Engine> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::NewPayload { payload, .. } => {
write!(
f,
"NewPayload(parent: {}, number: {}, hash: {})",
payload.parent_hash(),
payload.block_number(),
payload.block_hash()
)
}
Self::ForkchoiceUpdated { state, payload_attrs, .. } => {
// we don't want to print the entire payload attributes, because for OP this
// includes all txs
write!(
f,
"ForkchoiceUpdated {{ state: {state:?}, has_payload_attributes: {} }}",
payload_attrs.is_some()
)
}
Self::TransitionConfigurationExchanged => {
write!(f, "TransitionConfigurationExchanged")
}
}
}
}