docs/generated/contracts.mdgenerated from code

Reference · 2 min read

transport-spawn

Contracts: transport-spawn.

Source: crates/lvcs-net/src/transport/shell.rs.

ruston main
1/// Run the transport for `swarm` (from `build_swarm` with `keypair`) on the2/// current tokio runtime with `config`, listening on every IPv4 interface3/// (TCP and QUIC, ports the system picks) when `config.listen` is empty.4/// Each transport machine, built by `make` with its policy, is journaled by5/// that policy's step slot, whose close hands each step's commands to6/// `commands`; the shell runs them after the step (discussion:owner/222, discussion:owner/286, and7/// 403).8///9/// Events go to `events` in order, and the shell waits while `events` is10/// full, so the receiver must keep draining it. Commands go through the11/// returned handle (`TransportHandle::send`, which waits while the command12/// queue is full and returns the command when the transport has stopped);13/// the transport stops once every handle is dropped, and the task then14/// ends. Owner: `M3.transport`; the daemon (`M3.daemon`) runs it.15///16/// A swarm that panics (libp2p-relay 0.22.0's did, discussion:owner/676) is17/// restarted: after `TRANSPORT_RESTART_WAIT_MS` times the panics so far, a18/// fresh swarm from `keypair` and a fresh machine from `make` run on the19/// same handle, and `events` hears `Restarted` first, so its receiver20/// forgets every connection the old swarm held. The21/// `TRANSPORT_PANICS_MAX`th panic within `TRANSPORT_PANIC_WINDOW_MS` ends22/// the task instead, which its owner reads as a transport that can't be23/// restarted.24///25/// # Errors26///27/// [`NetError`] when a configured address does not parse, or the sync28/// protocol is already accepted.29pub fn spawn<P, M>(30    swarm: Swarm<Behaviour>,31    keypair: Keypair,32    config: &TransportConfig,33    events: mpsc::Sender<TransportEvent>,34    make: M,35    commands: Outputs<Command>,36) -> Result<(TransportHandle, JoinHandle<()>), NetError>37where38    P: sml::Policy<Scheduler: sml::Queued<TransportCore<P>, Completion: Send>> + 'static,39    TransportActor<P>: Send,40    M: FnMut() -> TransportActor<P> + Send + 'static,