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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Reth
impl RefUnwindSafe for Reth
impl Send for Reth
impl Sync for Reth
impl Unpin for Reth
impl UnwindSafe for Reth
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)