1use alloy_eips::BlockNumHash;
5use reth_chainspec::EthChainSpec;
6use reth_ethereum_primitives::EthPrimitives;
7use reth_node_api::{FullNodeComponents, HeaderTy, NodePrimitives, PrimitivesTy};
8use reth_node_core::node_config::NodeConfig;
9use std::fmt::Debug;
10use tokio::sync::mpsc;
11
12use crate::{ExExContext, ExExEvent, ExExNotificationsStream};
13
14pub struct ExExContextDyn<N: NodePrimitives = EthPrimitives> {
17 pub head: BlockNumHash,
19 pub config: NodeConfig<Box<dyn EthChainSpec<Header = N::BlockHeader> + 'static>>,
21 pub reth_config: reth_config::Config,
23 pub events: mpsc::UnboundedSender<ExExEvent>,
32 pub notifications: Box<dyn ExExNotificationsStream<N>>,
39}
40
41impl<N: NodePrimitives> Debug for ExExContextDyn<N> {
42 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
43 f.debug_struct("ExExContext")
44 .field("head", &self.head)
45 .field("config", &self.config)
46 .field("reth_config", &self.reth_config)
47 .field("events", &self.events)
48 .field("notifications", &"...")
49 .finish()
50 }
51}
52
53impl<Node> From<ExExContext<Node>> for ExExContextDyn<PrimitivesTy<Node::Types>>
54where
55 Node: FullNodeComponents,
56{
57 fn from(ctx: ExExContext<Node>) -> Self {
58 let config = ctx.config.map_chainspec(|chainspec| {
59 Box::new(chainspec) as Box<dyn EthChainSpec<Header = HeaderTy<Node::Types>>>
60 });
61 let notifications = Box::new(ctx.notifications) as Box<_>;
62
63 Self {
64 head: ctx.head,
65 config,
66 reth_config: ctx.reth_config,
67 events: ctx.events,
68 notifications,
69 }
70 }
71}