mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: tx forwarder
eth_sendRawTransaction will forward transactions into --upstream-rpc-url, if specified in cli args.
This commit is contained in:
25
src/main.rs
25
src/main.rs
@ -1,9 +1,15 @@
|
||||
use clap::Parser;
|
||||
use reth::builder::NodeHandle;
|
||||
use reth_hl::tx_forwarder::{self, EthForwarderApiServer};
|
||||
use reth_hl::{
|
||||
chainspec::parser::HlChainSpecParser,
|
||||
node::{cli::{Cli, HlNodeArgs}, storage::tables::Tables, HlNode},
|
||||
node::{
|
||||
cli::{Cli, HlNodeArgs},
|
||||
storage::tables::Tables,
|
||||
HlNode,
|
||||
},
|
||||
};
|
||||
use tracing::info;
|
||||
|
||||
// We use jemalloc for performance reasons
|
||||
#[cfg(all(feature = "jemalloc", unix))]
|
||||
@ -21,8 +27,21 @@ fn main() -> eyre::Result<()> {
|
||||
Cli::<HlChainSpecParser, HlNodeArgs>::parse().run(|builder, ext| async move {
|
||||
builder.builder.database.create_tables_for::<Tables>()?;
|
||||
let (node, engine_handle_tx) = HlNode::new(ext.block_source_args.parse().await?);
|
||||
let NodeHandle { node, node_exit_future: exit_future } =
|
||||
builder.node(node).launch().await?;
|
||||
let NodeHandle { node, node_exit_future: exit_future } = builder
|
||||
.node(node)
|
||||
.extend_rpc_modules(|ctx| {
|
||||
let upstream_rpc_url = ext.upstream_rpc_url;
|
||||
if let Some(upstream_rpc_url) = upstream_rpc_url {
|
||||
ctx.modules.replace_configured(
|
||||
tx_forwarder::EthForwarderExt::new(upstream_rpc_url.clone()).into_rpc(),
|
||||
)?;
|
||||
|
||||
info!("Transaction forwarding enabled");
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.launch()
|
||||
.await?;
|
||||
|
||||
engine_handle_tx.send(node.beacon_engine_handle.clone()).unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user