mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-31 17:01:58 +00:00
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:
@@ -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,
|
||||
}
|
||||
|
Reference in New Issue
Block a user