pub struct Reth { /* private fields */ }
Expand description
Builder for launching reth
.
§Panics
If spawn
is called without reth
being available in the user’s $PATH
§Example
use alloy_node_bindings::Reth;
let port = 8545u16;
let url = format!("http://localhost:{}", port).to_string();
let reth = Reth::new().instance(1).block_time("12sec").spawn();
drop(reth); // this will kill the instance
Implementations§
Source§impl Reth
impl Reth
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty Reth builder.
The instance number is set to a random number between 1 and 200 by default to reduce the
odds of port conflicts. This can be changed with Reth::instance
. Set to 0 to use the
default ports. 200 is the maximum number of instances that can be run set by Reth.
Sourcepub fn at(path: impl Into<PathBuf>) -> Self
pub fn at(path: impl Into<PathBuf>) -> Self
Creates a Reth builder which will execute reth
at the given path.
§Example
use alloy_node_bindings::Reth;
let reth = Reth::at("../reth/target/release/reth").spawn();
println!("Reth running at `{}`", reth.endpoint());
Sourcepub fn path<T: Into<PathBuf>>(self, path: T) -> Self
pub fn path<T: Into<PathBuf>>(self, path: T) -> Self
Sets the path
to the reth
executable
By default, it’s expected that reth
is in $PATH
, see also
std::process::Command::new()
Sourcepub const fn http_port(self, http_port: u16) -> Self
pub const fn http_port(self, http_port: u16) -> Self
Sets the HTTP port for the Reth instance. Note: this resets the instance number to 0 to allow for custom ports.
Sourcepub const fn ws_port(self, ws_port: u16) -> Self
pub const fn ws_port(self, ws_port: u16) -> Self
Sets the WS port for the Reth instance. Note: this resets the instance number to 0 to allow for custom ports.
Sourcepub const fn auth_port(self, auth_port: u16) -> Self
pub const fn auth_port(self, auth_port: u16) -> Self
Sets the auth port for the Reth instance. Note: this resets the instance number to 0 to allow for custom ports.
Sourcepub const fn p2p_port(self, p2p_port: u16) -> Self
pub const fn p2p_port(self, p2p_port: u16) -> Self
Sets the p2p port for the Reth instance. Note: this resets the instance number to 0 to allow for custom ports.
Sourcepub fn block_time(self, block_time: &str) -> Self
pub fn block_time(self, block_time: &str) -> Self
Sets the block time for the Reth instance.
Parses strings using https://docs.rs/humantime/latest/humantime/fn.parse_duration.html
This is only used if dev
mode is enabled.
Sourcepub const fn disable_discovery(self) -> Self
pub const fn disable_discovery(self) -> Self
Disables discovery for the Reth instance.
Sourcepub fn chain_or_path(self, chain_or_path: &str) -> Self
pub fn chain_or_path(self, chain_or_path: &str) -> Self
Sets the chain id for the Reth instance.
Sourcepub const fn enable_ipc(self) -> Self
pub const fn enable_ipc(self) -> Self
Enable IPC for the Reth instance.
Sourcepub const fn instance(self, instance: u16) -> Self
pub const fn instance(self, instance: u16) -> Self
Sets the instance number for the Reth instance. Set to 0 to use the default ports. By default, a random number between 1 and 200 is used.
Sourcepub fn genesis(self, genesis: Genesis) -> Self
pub fn genesis(self, genesis: Genesis) -> Self
Sets the genesis.json
for the Reth instance.
If this is set, reth will be initialized with reth init
and the --datadir
option will be
set to the same value as data_dir
.
This is destructive and will overwrite any existing data in the data directory.
Sourcepub fn arg<T: Into<OsString>>(self, arg: T) -> Self
pub fn arg<T: Into<OsString>>(self, arg: T) -> Self
Adds an argument to pass to reth
.
Pass any arg that is not supported by the builder.
Sourcepub fn args<I, S>(self, args: I) -> Self
pub fn args<I, S>(self, args: I) -> Self
Adds multiple arguments to pass to reth
.
Pass any args that is not supported by the builder.
Sourcepub fn spawn(self) -> RethInstance
pub fn spawn(self) -> RethInstance
Sourcepub fn try_spawn(self) -> Result<RethInstance, NodeError>
pub fn try_spawn(self) -> Result<RethInstance, NodeError>
Consumes the builder and spawns reth
. If spawning fails, returns an error.