rename PeriodicIdentifyBehaviour to PeriodicIdentify. (#738)

* rename PeriodicIdentifyBehaviour to PeriodicIdentify.

Signed-off-by: Daogang Tang <daogangtang@gmail.com>

* fix renaming PeriodicIdentifyBehaviour to PeriodicIdentify in misc/core-derive/tests/test.rs.

Signed-off-by: Daogang Tang <daogangtang@gmail.com>
This commit is contained in:
Daogang Tang
2018-12-06 20:30:55 +08:00
committed by Pierre Krieger
parent 9102266d70
commit 371905c876
3 changed files with 19 additions and 19 deletions

View File

@ -63,7 +63,7 @@ fn three_fields() {
struct Foo<TSubstream> { struct Foo<TSubstream> {
ping_dialer: libp2p::ping::PeriodicPing<TSubstream>, ping_dialer: libp2p::ping::PeriodicPing<TSubstream>,
ping_listener: libp2p::ping::PingListen<TSubstream>, ping_listener: libp2p::ping::PingListen<TSubstream>,
identify: libp2p::identify::PeriodicIdentifyBehaviour<TSubstream>, identify: libp2p::identify::PeriodicIdentify<TSubstream>,
#[behaviour(ignore)] #[behaviour(ignore)]
foo: String, foo: String,
} }
@ -79,14 +79,14 @@ fn event_handler() {
#[derive(NetworkBehaviour)] #[derive(NetworkBehaviour)]
struct Foo<TSubstream: libp2p::tokio_io::AsyncRead + libp2p::tokio_io::AsyncWrite> { struct Foo<TSubstream: libp2p::tokio_io::AsyncRead + libp2p::tokio_io::AsyncWrite> {
#[behaviour(handler = "foo")] #[behaviour(handler = "foo")]
identify: libp2p::identify::PeriodicIdentifyBehaviour<TSubstream>, identify: libp2p::identify::PeriodicIdentify<TSubstream>,
} }
impl<TSubstream: libp2p::tokio_io::AsyncRead + libp2p::tokio_io::AsyncWrite> Foo<TSubstream> { impl<TSubstream: libp2p::tokio_io::AsyncRead + libp2p::tokio_io::AsyncWrite> Foo<TSubstream> {
// TODO: for some reason, the parameter cannot be `PeriodicIdentifyBehaviourEvent` or we // TODO: for some reason, the parameter cannot be `PeriodicIdentifyEvent` or we
// get a compilation error ; figure out why or open an issue to Rust // get a compilation error ; figure out why or open an issue to Rust
fn foo<TTopology>(&mut self, ev: <libp2p::identify::PeriodicIdentifyBehaviour<TSubstream> as libp2p::core::swarm::NetworkBehaviour<TTopology>>::OutEvent) { fn foo<TTopology>(&mut self, ev: <libp2p::identify::PeriodicIdentify<TSubstream> as libp2p::core::swarm::NetworkBehaviour<TTopology>>::OutEvent) {
let libp2p::identify::PeriodicIdentifyBehaviourEvent::Identified { .. } = ev; let libp2p::identify::PeriodicIdentifyEvent::Identified { .. } = ev;
} }
} }
@ -102,7 +102,7 @@ fn custom_polling() {
#[behaviour(poll_method = "foo")] #[behaviour(poll_method = "foo")]
struct Foo<TSubstream> { struct Foo<TSubstream> {
ping: libp2p::ping::PeriodicPing<TSubstream>, ping: libp2p::ping::PeriodicPing<TSubstream>,
identify: libp2p::identify::PeriodicIdentifyBehaviour<TSubstream>, identify: libp2p::identify::PeriodicIdentify<TSubstream>,
} }
impl<TSubstream> Foo<TSubstream> { impl<TSubstream> Foo<TSubstream> {
@ -121,7 +121,7 @@ fn custom_event_no_polling() {
#[behaviour(out_event = "String")] #[behaviour(out_event = "String")]
struct Foo<TSubstream> { struct Foo<TSubstream> {
ping: libp2p::ping::PeriodicPing<TSubstream>, ping: libp2p::ping::PeriodicPing<TSubstream>,
identify: libp2p::identify::PeriodicIdentifyBehaviour<TSubstream>, identify: libp2p::identify::PeriodicIdentify<TSubstream>,
} }
fn foo<TSubstream: libp2p::tokio_io::AsyncRead + libp2p::tokio_io::AsyncWrite>() { fn foo<TSubstream: libp2p::tokio_io::AsyncRead + libp2p::tokio_io::AsyncWrite>() {
@ -136,7 +136,7 @@ fn custom_event_and_polling() {
#[behaviour(poll_method = "foo", out_event = "String")] #[behaviour(poll_method = "foo", out_event = "String")]
struct Foo<TSubstream> { struct Foo<TSubstream> {
ping: libp2p::ping::PeriodicPing<TSubstream>, ping: libp2p::ping::PeriodicPing<TSubstream>,
identify: libp2p::identify::PeriodicIdentifyBehaviour<TSubstream>, identify: libp2p::identify::PeriodicIdentify<TSubstream>,
} }
impl<TSubstream> Foo<TSubstream> { impl<TSubstream> Foo<TSubstream> {

View File

@ -83,7 +83,7 @@ extern crate void;
pub use self::id_transport::IdentifyTransport; pub use self::id_transport::IdentifyTransport;
pub use self::listen_layer::IdentifyListen; pub use self::listen_layer::IdentifyListen;
pub use self::periodic_id_layer::{PeriodicIdentifyBehaviour, PeriodicIdentifyBehaviourEvent}; pub use self::periodic_id_layer::{PeriodicIdentify, PeriodicIdentifyEvent};
pub mod listen_handler; pub mod listen_handler;
pub mod periodic_id_handler; pub mod periodic_id_handler;

View File

@ -28,29 +28,29 @@ use tokio_io::{AsyncRead, AsyncWrite};
/// Network behaviour that automatically identifies nodes periodically, and returns information /// Network behaviour that automatically identifies nodes periodically, and returns information
/// about them. /// about them.
pub struct PeriodicIdentifyBehaviour<TSubstream> { pub struct PeriodicIdentify<TSubstream> {
/// Events that need to be produced outside when polling.. /// Events that need to be produced outside when polling..
events: VecDeque<PeriodicIdentifyBehaviourEvent>, events: VecDeque<PeriodicIdentifyEvent>,
/// Marker to pin the generics. /// Marker to pin the generics.
marker: PhantomData<TSubstream>, marker: PhantomData<TSubstream>,
} }
impl<TSubstream> PeriodicIdentifyBehaviour<TSubstream> { impl<TSubstream> PeriodicIdentify<TSubstream> {
/// Creates a `PeriodicIdentifyBehaviour`. /// Creates a `PeriodicIdentify`.
pub fn new() -> Self { pub fn new() -> Self {
PeriodicIdentifyBehaviour { PeriodicIdentify {
events: VecDeque::new(), events: VecDeque::new(),
marker: PhantomData, marker: PhantomData,
} }
} }
} }
impl<TSubstream, TTopology> NetworkBehaviour<TTopology> for PeriodicIdentifyBehaviour<TSubstream> impl<TSubstream, TTopology> NetworkBehaviour<TTopology> for PeriodicIdentify<TSubstream>
where where
TSubstream: AsyncRead + AsyncWrite, TSubstream: AsyncRead + AsyncWrite,
{ {
type ProtocolsHandler = PeriodicIdentification<TSubstream>; type ProtocolsHandler = PeriodicIdentification<TSubstream>;
type OutEvent = PeriodicIdentifyBehaviourEvent; type OutEvent = PeriodicIdentifyEvent;
fn new_handler(&mut self) -> Self::ProtocolsHandler { fn new_handler(&mut self) -> Self::ProtocolsHandler {
PeriodicIdentification::new() PeriodicIdentification::new()
@ -68,7 +68,7 @@ where
match event { match event {
PeriodicIdentificationEvent::Identified(remote) => { PeriodicIdentificationEvent::Identified(remote) => {
self.events self.events
.push_back(PeriodicIdentifyBehaviourEvent::Identified { .push_back(PeriodicIdentifyEvent::Identified {
peer_id: peer_id, peer_id: peer_id,
info: remote.info, info: remote.info,
observed_addr: remote.observed_addr, observed_addr: remote.observed_addr,
@ -95,9 +95,9 @@ where
} }
} }
/// Event generated by the `PeriodicIdentifyBehaviour`. /// Event generated by the `PeriodicIdentify`.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum PeriodicIdentifyBehaviourEvent { pub enum PeriodicIdentifyEvent {
/// We obtained identification information from the remote /// We obtained identification information from the remote
Identified { Identified {
/// Peer that has been successfully identified. /// Peer that has been successfully identified.