feat: integrate builder (#6611)

This commit is contained in:
Matthias Seitz
2024-02-29 17:50:04 +01:00
committed by GitHub
parent 7d36206dfe
commit c5955f1305
73 changed files with 2201 additions and 3022 deletions

View File

@@ -14,6 +14,7 @@ use reth_node_core::{
},
},
};
use reth_payload_builder::PayloadBuilderHandle;
use reth_rpc::JwtSecret;
use reth_tasks::TaskExecutor;
use reth_tracing::tracing::{debug, info};
@@ -94,7 +95,7 @@ impl<Node: FullNodeComponents> fmt::Debug for RpcHooks<Node> {
}
/// Event hook that is called once the rpc server is started.
pub trait OnRpcStarted<Node: FullNodeComponents> {
pub trait OnRpcStarted<Node: FullNodeComponents>: Send {
/// The hook that is called once the rpc server is started.
fn on_rpc_started(
&self,
@@ -105,7 +106,7 @@ pub trait OnRpcStarted<Node: FullNodeComponents> {
impl<Node, F> OnRpcStarted<Node> for F
where
F: Fn(RpcContext<'_, Node>, RethRpcServerHandles) -> eyre::Result<()>,
F: Fn(RpcContext<'_, Node>, RethRpcServerHandles) -> eyre::Result<()> + Send,
Node: FullNodeComponents,
{
fn on_rpc_started(
@@ -124,14 +125,14 @@ impl<Node: FullNodeComponents> OnRpcStarted<Node> for () {
}
/// Event hook that is called when the rpc server is started.
pub trait ExtendRpcModules<Node: FullNodeComponents> {
pub trait ExtendRpcModules<Node: FullNodeComponents>: Send {
/// The hook that is called once the rpc server is started.
fn extend_rpc_modules(&self, ctx: RpcContext<'_, Node>) -> eyre::Result<()>;
}
impl<Node, F> ExtendRpcModules<Node> for F
where
F: Fn(RpcContext<'_, Node>) -> eyre::Result<()>,
F: Fn(RpcContext<'_, Node>) -> eyre::Result<()> + Send,
Node: FullNodeComponents,
{
fn extend_rpc_modules(&self, ctx: RpcContext<'_, Node>) -> eyre::Result<()> {
@@ -223,6 +224,26 @@ impl<'a, Node: FullNodeComponents> RpcContext<'a, Node> {
pub fn node(&self) -> &Node {
&self.node
}
/// Returns the transaction pool instance.
pub fn pool(&self) -> &Node::Pool {
self.node.pool()
}
/// Returns provider to interact with the node.
pub fn provider(&self) -> &Node::Provider {
self.node.provider()
}
/// Returns the handle to the network
pub fn network(&self) -> &NetworkHandle {
self.node.network()
}
/// Returns the handle to the payload builder service
pub fn payload_builder(&self) -> &PayloadBuilderHandle<Node::Engine> {
self.node.payload_builder()
}
}
/// Launch the rpc servers.