reth_node_builder/components/
payload.rs

1//! Payload service component for the node builder.
2
3use std::future::Future;
4
5use reth_node_api::NodeTypesWithEngine;
6use reth_payload_builder::PayloadBuilderHandle;
7use reth_transaction_pool::TransactionPool;
8
9use crate::{BuilderContext, FullNodeTypes};
10
11/// A type that knows how to spawn the payload service.
12pub trait PayloadServiceBuilder<Node: FullNodeTypes, Pool: TransactionPool>: Send {
13    /// Spawns the payload service and returns the handle to it.
14    ///
15    /// The [`BuilderContext`] is provided to allow access to the node's configuration.
16    fn spawn_payload_service(
17        self,
18        ctx: &BuilderContext<Node>,
19        pool: Pool,
20    ) -> impl Future<
21        Output = eyre::Result<PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>>,
22    > + Send;
23}
24
25impl<Node, F, Fut, Pool> PayloadServiceBuilder<Node, Pool> for F
26where
27    Node: FullNodeTypes,
28    Pool: TransactionPool,
29    F: Fn(&BuilderContext<Node>, Pool) -> Fut + Send,
30    Fut: Future<
31            Output = eyre::Result<
32                PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>,
33            >,
34        > + Send,
35{
36    fn spawn_payload_service(
37        self,
38        ctx: &BuilderContext<Node>,
39        pool: Pool,
40    ) -> impl Future<
41        Output = eyre::Result<PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>>,
42    > + Send {
43        self(ctx, pool)
44    }
45}