Skip to main content

Reth

Struct Reth 

Source
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 instance

Implementations§

Source§

impl Reth

Source

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.

Source

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());
Source

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()

Source

pub const fn dev(self) -> Self

Enable dev mode for the Reth instance.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub const fn disable_discovery(self) -> Self

Disables discovery for the Reth instance.

Source

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.

Source

pub const fn enable_ipc(self) -> Self

Enable IPC for the Reth instance.

Source

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.

Source

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.

Source

pub fn data_dir<T: Into<PathBuf>>(self, path: T) -> Self

Sets the data directory for reth.

Source

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.

Source

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.

Source

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.

Source

pub fn args<I, S>(self, args: I) -> Self
where I: IntoIterator<Item = S>, S: Into<OsString>,

Adds multiple arguments to pass to reth.

Pass any args that is not supported by the builder.

Source

pub fn spawn(self) -> RethInstance

Consumes the builder and spawns reth.

§Panics

If spawning the instance fails at any point.

Source

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§

Source§

impl Clone for Reth

Source§

fn clone(&self) -> Reth

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Reth

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Reth

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

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