pub fn build_transport(
    key_pair: Keypair,
    socket_timeout: Duration,
) -> Boxed<(PeerId, StreamMuxerBox)> {
    let multiplex = {
        let mut mplex = libp2p::mplex::MplexConfig::default();
        mplex.set_max_num_streams(1024 * 1024);
        let mut yamux = libp2p::yamux::YamuxConfig::default();
        yamux.set_max_num_streams(1024 * 1024);
        core::upgrade::SelectUpgrade::new(yamux, mplex)
    };
    let secio = SecioConfig::new(key_pair);

    let transport = {
        let tcp = libp2p::tcp::TcpConfig::new().nodelay(true);
        let tcp = dns::DnsConfig::new(tcp).expect("Can't build DNS");
        let websocket = libp2p::websocket::WsConfig::new(tcp.clone());
        tcp.or_transport(websocket)
    };

    transport
        .upgrade(core::upgrade::Version::V1)
        .authenticate(secio)
        .multiplex(multiplex)
        .timeout(socket_timeout)
        .boxed()
}
/// Creates transport that is common for all connections.
///
/// Transport is based on TCP with SECIO as the encryption layer and MPLEX otr YAMUX as
/// the multiplexing layer.
Creates transport that is common for all connections.
Transport is based on TCP with SECIO as the encryption layer and MPLEX otr YAMUX as
the multiplexing layer.
Creates transport that is common for all connections . Transport is based on TCP with SECIO as the encryption layer and MPLEX otr YAMUX as the multiplexing layer .
pub fn build_transport(
    key_pair: Keypair,
    socket_timeout: Duration,
) -> Boxed<(PeerId, StreamMuxerBox)> {
    let multiplex = {
        let mut mplex = libp2p::mplex::MplexConfig::default();
        mplex.set_max_num_streams(1024 * 1024);
        let mut yamux = libp2p::yamux::YamuxConfig::default();
        yamux.set_max_num_streams(1024 * 1024);
        core::upgrade::SelectUpgrade::new(yamux, mplex)
    };
    let secio = SecioConfig::new(key_pair);
    let transport = {
        let tcp = libp2p::tcp::TcpConfig::new().nodelay(true);
        let tcp = dns::DnsConfig::new(tcp).expect("Can't build DNS");
        let websocket = libp2p::websocket::WsConfig::new(tcp.clone());
        tcp.or_transport(websocket)
    };
    transport
        .upgrade(core::upgrade::Version::V1)
        .authenticate(secio)
        .multiplex(multiplex)
        .timeout(socket_timeout)
        .boxed()
}
pub fn build_transport ( key_pair : Keypair , socket_timeout : Duration , ) -> Boxed < ( PeerId , StreamMuxerBox ) > { let multiplex = { let mut mplex = libp2p :: mplex :: MplexConfig :: default ( ) ; mplex . set_max_num_streams ( 1024 * 1024 ) ; let mut yamux = libp2p :: yamux :: YamuxConfig :: default ( ) ; yamux . set_max_num_streams ( 1024 * 1024 ) ; core :: upgrade :: SelectUpgrade :: new ( yamux , mplex ) } ; let secio = SecioConfig :: new ( key_pair ) ; let transport = { let tcp = libp2p :: tcp :: TcpConfig :: new ( ) . nodelay ( true ) ; let tcp = dns :: DnsConfig :: new ( tcp ) . expect ( " " ) ; let websocket = libp2p :: websocket :: WsConfig :: new ( tcp . clone ( ) ) ; tcp . or_transport ( websocket ) } ; transport . upgrade ( core :: upgrade :: Version :: V1 ) . authenticate ( secio ) . multiplex ( multiplex ) . timeout ( socket_timeout ) . boxed ( ) }
Creates transport that is common for all connections.
Creates transport that is common for all connections .
key_pair
Keypair
socket_timeout
Duration