reth_node_builder/
exex.rs
1use std::future::Future;
4
5use futures::{future::BoxFuture, FutureExt};
6use reth_exex::ExExContext;
7use reth_node_api::FullNodeComponents;
8
9pub trait LaunchExEx<Node: FullNodeComponents>: Send {
11 fn launch(
16 self,
17 ctx: ExExContext<Node>,
18 ) -> impl Future<Output = eyre::Result<impl Future<Output = eyre::Result<()>> + Send>> + Send;
19}
20
21pub type BoxExEx = BoxFuture<'static, eyre::Result<()>>;
23
24pub trait BoxedLaunchExEx<Node: FullNodeComponents>: Send {
26 fn launch(self: Box<Self>, ctx: ExExContext<Node>)
28 -> BoxFuture<'static, eyre::Result<BoxExEx>>;
29}
30
31impl<E, Node> BoxedLaunchExEx<Node> for E
35where
36 E: LaunchExEx<Node> + Send + 'static,
37 Node: FullNodeComponents,
38{
39 fn launch(
40 self: Box<Self>,
41 ctx: ExExContext<Node>,
42 ) -> BoxFuture<'static, eyre::Result<BoxExEx>> {
43 async move {
44 let exex = LaunchExEx::launch(*self, ctx).await?;
45 Ok(Box::pin(exex) as BoxExEx)
46 }
47 .boxed()
48 }
49}
50
51impl<Node, F, Fut, E> LaunchExEx<Node> for F
54where
55 Node: FullNodeComponents,
56 F: FnOnce(ExExContext<Node>) -> Fut + Send,
57 Fut: Future<Output = eyre::Result<E>> + Send,
58 E: Future<Output = eyre::Result<()>> + Send,
59{
60 fn launch(
61 self,
62 ctx: ExExContext<Node>,
63 ) -> impl Future<Output = eyre::Result<impl Future<Output = eyre::Result<()>> + Send>> + Send
64 {
65 self(ctx)
66 }
67}