protocols/ping: Properly deprecate types with Ping prefix (#2937)

Co-authored-by: Elena Frank <elena.frank@protonmail.com>
Co-authored-by:  João Oliveira <hello@jxs.pt>
This commit is contained in:
Thomas Eizinger
2022-10-01 00:19:34 +10:00
committed by GitHub
parent cce296e55e
commit 1da75b2b25
17 changed files with 162 additions and 159 deletions

View File

@ -25,13 +25,12 @@ use futures::stream::StreamExt;
use libp2p::core::upgrade;
use libp2p::identify::{Identify, IdentifyConfig, IdentifyEvent};
use libp2p::multiaddr::Protocol;
use libp2p::ping::{Ping, PingConfig, PingEvent};
use libp2p::relay::v2::relay::{self, Relay};
use libp2p::swarm::{Swarm, SwarmEvent};
use libp2p::tcp::TcpTransport;
use libp2p::Transport;
use libp2p::{identity, NetworkBehaviour, PeerId};
use libp2p::{noise, Multiaddr};
use libp2p::{ping, Transport};
use std::error::Error;
use std::net::{Ipv4Addr, Ipv6Addr};
@ -59,7 +58,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let behaviour = Behaviour {
relay: Relay::new(local_peer_id, Default::default()),
ping: Ping::new(PingConfig::new()),
ping: ping::Behaviour::new(ping::Config::new()),
identify: Identify::new(IdentifyConfig::new(
"/TODO/0.0.1".to_string(),
local_key.public(),
@ -96,19 +95,19 @@ fn main() -> Result<(), Box<dyn Error>> {
#[behaviour(out_event = "Event", event_process = false)]
struct Behaviour {
relay: Relay,
ping: Ping,
ping: ping::Behaviour,
identify: Identify,
}
#[derive(Debug)]
enum Event {
Ping(PingEvent),
Ping(ping::Event),
Identify(IdentifyEvent),
Relay(relay::Event),
}
impl From<PingEvent> for Event {
fn from(e: PingEvent) -> Self {
impl From<ping::Event> for Event {
fn from(e: ping::Event) -> Self {
Event::Ping(e)
}
}