Skip to main content

TransportFactory

Trait TransportFactory 

Source
pub trait TransportFactory: Send + Sync {
    // Required methods
    fn get_bootstrap_addresses<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn create_server<'life0, 'life1, 'async_trait>(
        &'life0 self,
        base_path: &'life1 str,
        port: u16,
        force_local_network: bool,
    ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn TransportServer>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn rpc<'life0, 'life1, 'async_trait>(
        &'life0 self,
        address: &'life1 str,
        bytes: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

The pluggable network layer of the protocol — the single point where the crate touches “how do we move bytes around the world”.

A TransportFactory knows three things: (1) where to find the network’s bootstrap peers for initial peer discovery, (2) how to create a TransportServer that listens on a given port, and (3) how to perform an outbound unary RPC against a peer address. Everything above this layer — the RPC packet framing, PoW, peer tracking, Kademlia — is network- agnostic and simply calls TransportFactory::rpc.

Concrete implementations include the in-memory MemTransportFactory used by integration tests, FullHttpsTransportFactory in the server crate for production TLS+HTTPS, and WasmTransportFactory in the browser client that speaks HTTP via gloo-net. Swapping the factory on crate::tools::runtime_services::RuntimeServices changes the wire protocol without any other code having to care.

Required Methods§

Source

fn get_bootstrap_addresses<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn create_server<'life0, 'life1, 'async_trait>( &'life0 self, base_path: &'life1 str, port: u16, force_local_network: bool, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn TransportServer>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn rpc<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 str, bytes: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§