pub struct Devnet { /* private fields */ }Expand description
A local devnet composed of multiple nodes.
Call shutdown before dropping it. Dropped without one,
the nodes it started are not stopped, and its run directory is left,
locked until the process exits so that no other run deletes it while they
may still be writing there.
Implementations§
Source§impl Devnet
impl Devnet
Sourcepub async fn new(config: DevnetConfig) -> Result<Self>
pub async fn new(config: DevnetConfig) -> Result<Self>
Create a new devnet with the given configuration.
Creates this run’s own data directory inside config.data_dir, after
removing any that earlier runs left there and that are over and not
kept (see DevnetConfig::data_dir).
§Errors
Returns DevnetError::Config if the configuration is invalid (e.g. bootstrap
count exceeds node count or port range overflow).
Returns DevnetError::Io if the data directory cannot be created.
Sourcepub async fn start(&mut self) -> Result<()>
pub async fn start(&mut self) -> Result<()>
Start the devnet.
§Errors
Returns DevnetError::Startup if any node fails to start, or
DevnetError::Stabilization if the network does not stabilize within the timeout.
Sourcepub async fn shutdown(&mut self) -> Result<()>
pub async fn shutdown(&mut self) -> Result<()>
Shutdown the devnet.
Stops every node, then removes the run’s data directory, but only if they have all stopped writing to it. A node that has not, because a request is still being handled after a few seconds or its P2P node failed to shut down, leaves the directory, locked until the process exits; the next run removes it then.
§Errors
Returns DevnetError::Io if the data directory cleanup fails.
Sourcepub fn cancellation_token(&self) -> CancellationToken
pub fn cancellation_token(&self) -> CancellationToken
A token that stops this devnet’s start when cancelled.
A start in progress returns an error at its next safe point: between
node spawns, or while it waits for nodes to come up or the network to
stabilize. Every node it started is registered by then, so a following
shutdown stops them all before it removes the data
directory. Dropping a start future part-way instead can leave a node
running unregistered, still writing into that directory. It is the same
token shutdown cancels.
Sourcepub fn config(&self) -> &DevnetConfig
pub fn config(&self) -> &DevnetConfig
Get devnet configuration.
Sourcepub fn bootstrap_addrs(&self) -> Vec<MultiAddr>
pub fn bootstrap_addrs(&self) -> Vec<MultiAddr>
Get bootstrap addresses.
Sourcepub fn browser_listener_diagnostics(&self) -> Vec<WebRtcServerSnapshot>
pub fn browser_listener_diagnostics(&self) -> Vec<WebRtcServerSnapshot>
Snapshot every browser listener, including counters retained after shutdown.
Sourcepub fn browser_endpoints(&self) -> Vec<BrowserBootstrapNode>
pub fn browser_endpoints(&self) -> Vec<BrowserBootstrapNode>
Get every direct browser endpoint in this devnet.
Sourcepub async fn browser_payment_network(&self) -> Result<BrowserPaymentNetwork>
pub async fn browser_payment_network(&self) -> Result<BrowserPaymentNetwork>
Public EVM chain and contracts advertised to direct browser clients.
§Errors
Returns DevnetError::Config if a custom RPC cannot report its chain ID.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Devnet
impl !UnwindSafe for Devnet
impl Freeze for Devnet
impl Send for Devnet
impl Sync for Devnet
impl Unpin for Devnet
impl UnsafeUnpin for Devnet
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 more