core/src/transport: Poll Transport directly, remove Transport::Listener (#2652)

Remove the concept of individual `Transport::Listener` streams from `Transport`.
Instead the `Transport` is polled directly via `Transport::poll`. The
`Transport` is now responsible for driving its listeners.
This commit is contained in:
Elena Frank
2022-07-04 04:16:57 +02:00
committed by GitHub
parent b28cdb31f9
commit 62622a1bad
59 changed files with 2094 additions and 2044 deletions

View File

@ -44,10 +44,11 @@ use libp2p::{
noise, ping,
pnet::{PnetConfig, PreSharedKey},
swarm::{NetworkBehaviourEventProcess, SwarmEvent},
tcp::TcpConfig,
tcp::TcpTransport,
yamux::YamuxConfig,
Multiaddr, NetworkBehaviour, PeerId, Swarm, Transport,
};
use libp2p_tcp::GenTcpConfig;
use std::{env, error::Error, fs, path::Path, str::FromStr, time::Duration};
/// Builds the transport that serves as a common ground for all connections.
@ -61,7 +62,7 @@ pub fn build_transport(
let noise_config = noise::NoiseConfig::xx(noise_keys).into_authenticated();
let yamux_config = YamuxConfig::default();
let base_transport = TcpConfig::new().nodelay(true);
let base_transport = TcpTransport::new(GenTcpConfig::default().nodelay(true));
let maybe_encrypted = match psk {
Some(psk) => EitherTransport::Left(
base_transport.and_then(move |socket, _| PnetConfig::new(psk).handshake(socket)),