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

@ -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.