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> {
ping_dialer: libp2p::ping::PeriodicPing<TSubstream>,
ping_listener: libp2p::ping::PingListen<TSubstream>,
identify: libp2p::identify::PeriodicIdentifyBehaviour<TSubstream>,
identify: libp2p::identify::PeriodicIdentify<TSubstream>,
#[behaviour(ignore)]
foo: String,
}
@ -79,14 +79,14 @@ fn event_handler() {
#[derive(NetworkBehaviour)]
struct Foo<TSubstream: libp2p::tokio_io::AsyncRead + libp2p::tokio_io::AsyncWrite> {
#[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> {
// 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
fn foo<TTopology>(&mut self, ev: <libp2p::identify::PeriodicIdentifyBehaviour<TSubstream> as libp2p::core::swarm::NetworkBehaviour<TTopology>>::OutEvent) {
let libp2p::identify::PeriodicIdentifyBehaviourEvent::Identified { .. } = ev;
fn foo<TTopology>(&mut self, ev: <libp2p::identify::PeriodicIdentify<TSubstream> as libp2p::core::swarm::NetworkBehaviour<TTopology>>::OutEvent) {
let libp2p::identify::PeriodicIdentifyEvent::Identified { .. } = ev;
}
}
@ -102,7 +102,7 @@ fn custom_polling() {
#[behaviour(poll_method = "foo")]
struct Foo<TSubstream> {
ping: libp2p::ping::PeriodicPing<TSubstream>,
identify: libp2p::identify::PeriodicIdentifyBehaviour<TSubstream>,
identify: libp2p::identify::PeriodicIdentify<TSubstream>,
}
impl<TSubstream> Foo<TSubstream> {
@ -121,7 +121,7 @@ fn custom_event_no_polling() {
#[behaviour(out_event = "String")]
struct Foo<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>() {
@ -136,7 +136,7 @@ fn custom_event_and_polling() {
#[behaviour(poll_method = "foo", out_event = "String")]
struct Foo<TSubstream> {
ping: libp2p::ping::PeriodicPing<TSubstream>,
identify: libp2p::identify::PeriodicIdentifyBehaviour<TSubstream>,
identify: libp2p::identify::PeriodicIdentify<TSubstream>,
}
impl<TSubstream> Foo<TSubstream> {

View File

@ -83,7 +83,7 @@ extern crate void;
pub use self::id_transport::IdentifyTransport;
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 periodic_id_handler;

View File

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