mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-24 15:21:33 +00:00
protocols/ping: Revise naming of symbols (#2215)
Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
@ -41,8 +41,7 @@ use libp2p::{
|
||||
identify::{Identify, IdentifyConfig, IdentifyEvent},
|
||||
identity,
|
||||
multiaddr::Protocol,
|
||||
noise,
|
||||
ping::{self, Ping, PingConfig, PingEvent},
|
||||
noise, ping,
|
||||
pnet::{PnetConfig, PreSharedKey},
|
||||
swarm::{NetworkBehaviourEventProcess, SwarmEvent},
|
||||
tcp::TcpConfig,
|
||||
@ -167,7 +166,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
struct MyBehaviour {
|
||||
gossipsub: Gossipsub,
|
||||
identify: Identify,
|
||||
ping: Ping,
|
||||
ping: ping::Behaviour,
|
||||
}
|
||||
|
||||
impl NetworkBehaviourEventProcess<IdentifyEvent> for MyBehaviour {
|
||||
@ -196,14 +195,13 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl NetworkBehaviourEventProcess<PingEvent> for MyBehaviour {
|
||||
impl NetworkBehaviourEventProcess<ping::Event> for MyBehaviour {
|
||||
// Called when `ping` produces an event.
|
||||
fn inject_event(&mut self, event: PingEvent) {
|
||||
use ping::handler::{PingFailure, PingSuccess};
|
||||
fn inject_event(&mut self, event: ping::Event) {
|
||||
match event {
|
||||
PingEvent {
|
||||
ping::Event {
|
||||
peer,
|
||||
result: Result::Ok(PingSuccess::Ping { rtt }),
|
||||
result: Result::Ok(ping::Success::Ping { rtt }),
|
||||
} => {
|
||||
println!(
|
||||
"ping: rtt to {} is {} ms",
|
||||
@ -211,29 +209,29 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
rtt.as_millis()
|
||||
);
|
||||
}
|
||||
PingEvent {
|
||||
ping::Event {
|
||||
peer,
|
||||
result: Result::Ok(PingSuccess::Pong),
|
||||
result: Result::Ok(ping::Success::Pong),
|
||||
} => {
|
||||
println!("ping: pong from {}", peer.to_base58());
|
||||
}
|
||||
PingEvent {
|
||||
ping::Event {
|
||||
peer,
|
||||
result: Result::Err(PingFailure::Timeout),
|
||||
result: Result::Err(ping::Failure::Timeout),
|
||||
} => {
|
||||
println!("ping: timeout to {}", peer.to_base58());
|
||||
}
|
||||
PingEvent {
|
||||
ping::Event {
|
||||
peer,
|
||||
result: Result::Err(PingFailure::Unsupported),
|
||||
result: Result::Err(ping::Failure::Unsupported),
|
||||
} => {
|
||||
println!("ping: {} does not support ping protocol", peer.to_base58());
|
||||
}
|
||||
PingEvent {
|
||||
ping::Event {
|
||||
peer,
|
||||
result: Result::Err(PingFailure::Other { error }),
|
||||
result: Result::Err(ping::Failure::Other { error }),
|
||||
} => {
|
||||
println!("ping: failure with {}: {}", peer.to_base58(), error);
|
||||
println!("ping: ping::Failure with {}: {}", peer.to_base58(), error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -255,7 +253,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
"/ipfs/0.1.0".into(),
|
||||
local_key.public(),
|
||||
)),
|
||||
ping: Ping::new(PingConfig::new()),
|
||||
ping: ping::Behaviour::new(ping::Config::new()),
|
||||
};
|
||||
|
||||
println!("Subscribing to {:?}", gossipsub_topic);
|
||||
|
Reference in New Issue
Block a user