pub struct Reth { /* private fields */ }Expand description
Builder for launching reth.
Reth::new configures a regular node. Call Reth::dev for an isolated development chain.
Reth::spawn panics on any startup failure; use Reth::try_spawn to handle errors.
§Example
use alloy_node_bindings::Reth;
let reth = Reth::new().dev().block_time("12s").try_spawn()?;
println!("Reth is listening at {}", reth.endpoint());
drop(reth); // this will kill the instanceImplementations§
Source§impl Reth
impl Reth
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a Reth builder in regular (non-dev) mode.
The instance number is chosen from 1..=199 to reduce the odds of port conflicts. Change it
with Reth::instance, or set it to zero to use Reth’s base default ports. Reth permits
instance numbers up to 200.
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("/path/to/reth").dev().try_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 fn host<T: Into<String>>(self, host: T) -> Self
pub fn host<T: Into<String>>(self, host: T) -> Self
Sets the host which will be used when the reth instance is launched.
Defaults to localhost.
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 a dev-mode Reth instance.
Reth parses this with humantime syntax, such as "12s". The setting is ignored unless
Self::dev is also 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 name or path to a chain spec for the Reth instance.
Passed through to reth node --chain <name-or-path>. To launch Reth with a custom genesis,
write the genesis or chain specification to disk and pass that path here.
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 Reth instance number. Set to zero to use the base default ports.
By default, a random number in 1..=199 is used; Reth permits values up to 200.
Sourcepub fn ipc_path<T: Into<PathBuf>>(self, path: T) -> Self
pub fn ipc_path<T: Into<PathBuf>>(self, path: T) -> Self
Sets the IPC path for the socket.
This also enables IPC, as setting a path implies the intent to use IPC.
Sourcepub fn genesis(self, genesis: Genesis) -> Self
pub fn genesis(self, genesis: Genesis) -> Self
Stores the genesis configuration on the returned RethInstance.
The spawned node can be inspected through RethInstance::genesis to recover the genesis
value that was supplied to the builder. To launch Reth with a custom genesis or chain
specification, write that specification to disk and pass the path with
Reth::chain_or_path.
Sourcepub const fn keep_stdout(self) -> Self
pub const fn keep_stdout(self) -> Self
Keep the handle to reth’s stdout in order to read from it.
Caution: if the stdout handle isn’t used, this can end up blocking.
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, spawns reth, and waits for its services to report ready.
Returns an error if the process cannot be started, reports a fatal startup error, or does
not become ready before NODE_STARTUP_TIMEOUT is observed. The deadline is checked
between complete stdout lines; a live process that emits no newline can block this call
past the deadline.
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 UnsafeUnpin 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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 1072 bytes