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

@ -32,7 +32,7 @@ use libp2p::noise;
use libp2p::ping::{Ping, PingConfig, PingEvent};
use libp2p::relay::v2::client::{self, Client};
use libp2p::swarm::{SwarmBuilder, SwarmEvent};
use libp2p::tcp::TcpConfig;
use libp2p::tcp::{GenTcpConfig, TcpTransport};
use libp2p::Transport;
use libp2p::{identity, NetworkBehaviour, PeerId};
use log::info;
@ -95,7 +95,10 @@ fn main() -> Result<(), Box<dyn Error>> {
let transport = OrTransport::new(
relay_transport,
block_on(DnsConfig::system(TcpConfig::new().port_reuse(true))).unwrap(),
block_on(DnsConfig::system(TcpTransport::new(
GenTcpConfig::default().port_reuse(true),
)))
.unwrap(),
)
.upgrade(upgrade::Version::V1)
.authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated())