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

@@ -22,7 +22,7 @@ use futures::StreamExt;
use libp2p::core::identity;
use libp2p::core::PeerId;
use libp2p::identify::{Identify, IdentifyConfig, IdentifyEvent};
use libp2p::ping::{Ping, PingConfig, PingEvent, PingSuccess};
use libp2p::ping;
use libp2p::swarm::{Swarm, SwarmEvent};
use libp2p::{development_transport, rendezvous};
use libp2p::{Multiaddr, NetworkBehaviour};
@@ -47,8 +47,8 @@ async fn main() {
identity.public(),
)),
rendezvous: rendezvous::client::Behaviour::new(identity.clone()),
ping: Ping::new(
PingConfig::new()
ping: ping::Behaviour::new(
ping::Config::new()
.with_interval(Duration::from_secs(1))
.with_keep_alive(true),
),
@@ -100,9 +100,9 @@ async fn main() {
log::error!("Failed to register {}", error);
return;
}
SwarmEvent::Behaviour(MyEvent::Ping(PingEvent {
SwarmEvent::Behaviour(MyEvent::Ping(ping::Event {
peer,
result: Ok(PingSuccess::Ping { rtt }),
result: Ok(ping::Success::Ping { rtt }),
})) if peer != rendezvous_point => {
log::info!("Ping to {} is {}ms", peer, rtt.as_millis())
}
@@ -117,7 +117,7 @@ async fn main() {
enum MyEvent {
Rendezvous(rendezvous::client::Event),
Identify(IdentifyEvent),
Ping(PingEvent),
Ping(ping::Event),
}
impl From<rendezvous::client::Event> for MyEvent {
@@ -132,8 +132,8 @@ impl From<IdentifyEvent> for MyEvent {
}
}
impl From<PingEvent> for MyEvent {
fn from(event: PingEvent) -> Self {
impl From<ping::Event> for MyEvent {
fn from(event: ping::Event) -> Self {
MyEvent::Ping(event)
}
}
@@ -144,5 +144,5 @@ impl From<PingEvent> for MyEvent {
struct MyBehaviour {
identify: Identify,
rendezvous: rendezvous::client::Behaviour,
ping: Ping,
ping: ping::Behaviour,
}