mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-04-25 11:02:12 +00:00
Behavior -> Behaviour (#650)
This commit is contained in:
parent
23bcd44f18
commit
37994b34e7
@ -29,4 +29,4 @@ pub mod swarm;
|
|||||||
pub use self::node::Substream;
|
pub use self::node::Substream;
|
||||||
pub use self::handled_node::{NodeHandlerEvent, NodeHandlerEndpoint};
|
pub use self::handled_node::{NodeHandlerEvent, NodeHandlerEndpoint};
|
||||||
pub use self::raw_swarm::{ConnectedPoint, Peer, RawSwarm, RawSwarmEvent};
|
pub use self::raw_swarm::{ConnectedPoint, Peer, RawSwarm, RawSwarmEvent};
|
||||||
pub use self::swarm::{Swarm, NetworkBehavior, NetworkBehaviorAction};
|
pub use self::swarm::{Swarm, NetworkBehaviour, NetworkBehaviourAction};
|
||||||
|
@ -35,12 +35,12 @@ use std::{fmt, io, ops::{Deref, DerefMut}};
|
|||||||
/// Contains the state of the network, plus the way it should behave.
|
/// Contains the state of the network, plus the way it should behave.
|
||||||
pub struct Swarm<TTransport, TBehaviour, TTopology>
|
pub struct Swarm<TTransport, TBehaviour, TTopology>
|
||||||
where TTransport: Transport,
|
where TTransport: Transport,
|
||||||
TBehaviour: NetworkBehavior,
|
TBehaviour: NetworkBehaviour,
|
||||||
{
|
{
|
||||||
raw_swarm: RawSwarm<
|
raw_swarm: RawSwarm<
|
||||||
TTransport,
|
TTransport,
|
||||||
<<TBehaviour as NetworkBehavior>::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
||||||
<<TBehaviour as NetworkBehavior>::ProtocolsHandler as ProtocolsHandler>::OutEvent,
|
<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as ProtocolsHandler>::OutEvent,
|
||||||
NodeHandlerWrapper<TBehaviour::ProtocolsHandler>,
|
NodeHandlerWrapper<TBehaviour::ProtocolsHandler>,
|
||||||
>,
|
>,
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ where TTransport: Transport,
|
|||||||
|
|
||||||
impl<TTransport, TBehaviour, TTopology> Deref for Swarm<TTransport, TBehaviour, TTopology>
|
impl<TTransport, TBehaviour, TTopology> Deref for Swarm<TTransport, TBehaviour, TTopology>
|
||||||
where TTransport: Transport,
|
where TTransport: Transport,
|
||||||
TBehaviour: NetworkBehavior,
|
TBehaviour: NetworkBehaviour,
|
||||||
{
|
{
|
||||||
type Target = TBehaviour;
|
type Target = TBehaviour;
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ where TTransport: Transport,
|
|||||||
|
|
||||||
impl<TTransport, TBehaviour, TTopology> DerefMut for Swarm<TTransport, TBehaviour, TTopology>
|
impl<TTransport, TBehaviour, TTopology> DerefMut for Swarm<TTransport, TBehaviour, TTopology>
|
||||||
where TTransport: Transport,
|
where TTransport: Transport,
|
||||||
TBehaviour: NetworkBehavior,
|
TBehaviour: NetworkBehaviour,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
@ -76,7 +76,7 @@ where TTransport: Transport,
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<TTransport, TBehaviour, TMuxer, TTopology> Swarm<TTransport, TBehaviour, TTopology>
|
impl<TTransport, TBehaviour, TMuxer, TTopology> Swarm<TTransport, TBehaviour, TTopology>
|
||||||
where TBehaviour: NetworkBehavior,
|
where TBehaviour: NetworkBehaviour,
|
||||||
TMuxer: StreamMuxer + Send + Sync + 'static,
|
TMuxer: StreamMuxer + Send + Sync + 'static,
|
||||||
<TMuxer as StreamMuxer>::OutboundSubstream: Send + 'static,
|
<TMuxer as StreamMuxer>::OutboundSubstream: Send + 'static,
|
||||||
<TMuxer as StreamMuxer>::Substream: Send + 'static,
|
<TMuxer as StreamMuxer>::Substream: Send + 'static,
|
||||||
@ -169,7 +169,7 @@ where TBehaviour: NetworkBehavior,
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<TTransport, TBehaviour, TMuxer, TTopology> Stream for Swarm<TTransport, TBehaviour, TTopology>
|
impl<TTransport, TBehaviour, TMuxer, TTopology> Stream for Swarm<TTransport, TBehaviour, TTopology>
|
||||||
where TBehaviour: NetworkBehavior,
|
where TBehaviour: NetworkBehaviour,
|
||||||
TMuxer: StreamMuxer + Send + Sync + 'static,
|
TMuxer: StreamMuxer + Send + Sync + 'static,
|
||||||
<TMuxer as StreamMuxer>::OutboundSubstream: Send + 'static,
|
<TMuxer as StreamMuxer>::OutboundSubstream: Send + 'static,
|
||||||
<TMuxer as StreamMuxer>::Substream: Send + 'static,
|
<TMuxer as StreamMuxer>::Substream: Send + 'static,
|
||||||
@ -231,16 +231,16 @@ where TBehaviour: NetworkBehavior,
|
|||||||
match self.behaviour.poll() {
|
match self.behaviour.poll() {
|
||||||
Async::NotReady if raw_swarm_not_ready => return Ok(Async::NotReady),
|
Async::NotReady if raw_swarm_not_ready => return Ok(Async::NotReady),
|
||||||
Async::NotReady => (),
|
Async::NotReady => (),
|
||||||
Async::Ready(NetworkBehaviorAction::GenerateEvent(event)) => {
|
Async::Ready(NetworkBehaviourAction::GenerateEvent(event)) => {
|
||||||
return Ok(Async::Ready(Some(event)));
|
return Ok(Async::Ready(Some(event)));
|
||||||
},
|
},
|
||||||
Async::Ready(NetworkBehaviorAction::DialAddress { address }) => {
|
Async::Ready(NetworkBehaviourAction::DialAddress { address }) => {
|
||||||
let _ = Swarm::dial_addr(self, address);
|
let _ = Swarm::dial_addr(self, address);
|
||||||
},
|
},
|
||||||
Async::Ready(NetworkBehaviorAction::DialPeer { peer_id }) => {
|
Async::Ready(NetworkBehaviourAction::DialPeer { peer_id }) => {
|
||||||
Swarm::dial(self, peer_id)
|
Swarm::dial(self, peer_id)
|
||||||
},
|
},
|
||||||
Async::Ready(NetworkBehaviorAction::SendEvent { peer_id, event }) => {
|
Async::Ready(NetworkBehaviourAction::SendEvent { peer_id, event }) => {
|
||||||
if let Some(mut peer) = self.raw_swarm.peer(peer_id).as_connected() {
|
if let Some(mut peer) = self.raw_swarm.peer(peer_id).as_connected() {
|
||||||
peer.send_event(event);
|
peer.send_event(event);
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ where TBehaviour: NetworkBehavior,
|
|||||||
///
|
///
|
||||||
/// This trait has been designed to be composable. Multiple implementations can be combined into
|
/// This trait has been designed to be composable. Multiple implementations can be combined into
|
||||||
/// one that handles all the behaviours at once.
|
/// one that handles all the behaviours at once.
|
||||||
pub trait NetworkBehavior {
|
pub trait NetworkBehaviour {
|
||||||
/// Handler for all the protocols the network supports.
|
/// Handler for all the protocols the network supports.
|
||||||
type ProtocolsHandler: ProtocolsHandler;
|
type ProtocolsHandler: ProtocolsHandler;
|
||||||
/// Event generated by the swarm.
|
/// Event generated by the swarm.
|
||||||
@ -284,12 +284,12 @@ pub trait NetworkBehavior {
|
|||||||
/// Polls for things that swarm should do.
|
/// Polls for things that swarm should do.
|
||||||
///
|
///
|
||||||
/// This API mimics the API of the `Stream` trait.
|
/// This API mimics the API of the `Stream` trait.
|
||||||
fn poll(&mut self) -> Async<NetworkBehaviorAction<<Self::ProtocolsHandler as ProtocolsHandler>::InEvent, Self::OutEvent>>;
|
fn poll(&mut self) -> Async<NetworkBehaviourAction<<Self::ProtocolsHandler as ProtocolsHandler>::InEvent, Self::OutEvent>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Action to perform.
|
/// Action to perform.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum NetworkBehaviorAction<TInEvent, TOutEvent> {
|
pub enum NetworkBehaviourAction<TInEvent, TOutEvent> {
|
||||||
/// Generate an event for the outside.
|
/// Generate an event for the outside.
|
||||||
GenerateEvent(TOutEvent),
|
GenerateEvent(TOutEvent),
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ struct DummyConnection {
|
|||||||
state: DummyConnectionState,
|
state: DummyConnectionState,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `DummyMuxer` implements `StreamMuxer` and methods to control its behavior when used in tests
|
/// `DummyMuxer` implements `StreamMuxer` and methods to control its behaviour when used in tests
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct DummyMuxer {
|
pub struct DummyMuxer {
|
||||||
in_connection: DummyConnection,
|
in_connection: DummyConnection,
|
||||||
|
@ -40,8 +40,8 @@ pub fn hello_macro_derive(input: TokenStream) -> TokenStream {
|
|||||||
fn build(ast: &DeriveInput) -> TokenStream {
|
fn build(ast: &DeriveInput) -> TokenStream {
|
||||||
match ast.data {
|
match ast.data {
|
||||||
Data::Struct(ref s) => build_struct(ast, s),
|
Data::Struct(ref s) => build_struct(ast, s),
|
||||||
Data::Enum(_) => unimplemented!("Deriving NetworkBehavior is not implemented for enums"),
|
Data::Enum(_) => unimplemented!("Deriving NetworkBehaviour is not implemented for enums"),
|
||||||
Data::Union(_) => unimplemented!("Deriving NetworkBehavior is not implemented for unions"),
|
Data::Union(_) => unimplemented!("Deriving NetworkBehaviour is not implemented for unions"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,9 +49,9 @@ fn build(ast: &DeriveInput) -> TokenStream {
|
|||||||
fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||||
let name = &ast.ident;
|
let name = &ast.ident;
|
||||||
let (_, ty_generics, where_clause) = ast.generics.split_for_impl();
|
let (_, ty_generics, where_clause) = ast.generics.split_for_impl();
|
||||||
let trait_to_impl = quote!{::libp2p::core::nodes::swarm::NetworkBehavior};
|
let trait_to_impl = quote!{::libp2p::core::nodes::swarm::NetworkBehaviour};
|
||||||
let either_ident = quote!{::libp2p::core::either::EitherOutput};
|
let either_ident = quote!{::libp2p::core::either::EitherOutput};
|
||||||
let network_behaviour_action = quote!{::libp2p::core::nodes::swarm::NetworkBehaviorAction};
|
let network_behaviour_action = quote!{::libp2p::core::nodes::swarm::NetworkBehaviourAction};
|
||||||
let protocols_handler = quote!{::libp2p::core::protocols_handler::ProtocolsHandler};
|
let protocols_handler = quote!{::libp2p::core::protocols_handler::ProtocolsHandler};
|
||||||
let proto_select_ident = quote!{::libp2p::core::protocols_handler::ProtocolsHandlerSelect};
|
let proto_select_ident = quote!{::libp2p::core::protocols_handler::ProtocolsHandlerSelect};
|
||||||
let peer_id = quote!{::libp2p::core::PeerId};
|
let peer_id = quote!{::libp2p::core::PeerId};
|
||||||
|
@ -74,7 +74,7 @@ fn event_handler() {
|
|||||||
impl<TSubstream: libp2p::tokio_io::AsyncRead + libp2p::tokio_io::AsyncWrite + Send + Sync + 'static> Foo<TSubstream> {
|
impl<TSubstream: libp2p::tokio_io::AsyncRead + libp2p::tokio_io::AsyncWrite + Send + Sync + 'static> Foo<TSubstream> {
|
||||||
// TODO: for some reason, the parameter cannot be `PeriodicIdentifyBehaviourEvent` or we
|
// TODO: for some reason, the parameter cannot be `PeriodicIdentifyBehaviourEvent` 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(&mut self, ev: <libp2p::identify::PeriodicIdentifyBehaviour<TSubstream> as libp2p::core::nodes::NetworkBehavior>::OutEvent) {
|
fn foo(&mut self, ev: <libp2p::identify::PeriodicIdentifyBehaviour<TSubstream> as libp2p::core::nodes::NetworkBehaviour>::OutEvent) {
|
||||||
let libp2p::identify::PeriodicIdentifyBehaviourEvent::Identified { .. } = ev;
|
let libp2p::identify::PeriodicIdentifyBehaviourEvent::Identified { .. } = ev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ fn custom_polling() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<TSubstream> Foo<TSubstream> {
|
impl<TSubstream> Foo<TSubstream> {
|
||||||
fn foo<T>(&mut self) -> libp2p::futures::Async<libp2p::core::nodes::NetworkBehaviorAction<T, ()>> { libp2p::futures::Async::NotReady }
|
fn foo<T>(&mut self) -> libp2p::futures::Async<libp2p::core::nodes::NetworkBehaviourAction<T, ()>> { libp2p::futures::Async::NotReady }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +117,6 @@ fn custom_event_and_polling() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<TSubstream> Foo<TSubstream> {
|
impl<TSubstream> Foo<TSubstream> {
|
||||||
fn foo<T>(&mut self) -> libp2p::futures::Async<libp2p::core::nodes::NetworkBehaviorAction<T, String>> { libp2p::futures::Async::NotReady }
|
fn foo<T>(&mut self) -> libp2p::futures::Async<libp2p::core::nodes::NetworkBehaviourAction<T, String>> { libp2p::futures::Async::NotReady }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
use cuckoofilter::CuckooFilter;
|
use cuckoofilter::CuckooFilter;
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use handler::FloodsubHandler;
|
use handler::FloodsubHandler;
|
||||||
use libp2p_core::nodes::{ConnectedPoint, NetworkBehavior, NetworkBehaviorAction};
|
use libp2p_core::nodes::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||||
use libp2p_core::{protocols_handler::ProtocolsHandler, PeerId};
|
use libp2p_core::{protocols_handler::ProtocolsHandler, PeerId};
|
||||||
use protocol::{FloodsubMessage, FloodsubRpc, FloodsubSubscription, FloodsubSubscriptionAction};
|
use protocol::{FloodsubMessage, FloodsubRpc, FloodsubSubscription, FloodsubSubscriptionAction};
|
||||||
use rand;
|
use rand;
|
||||||
@ -35,7 +35,7 @@ use topic::{Topic, TopicHash};
|
|||||||
/// about them.
|
/// about them.
|
||||||
pub struct FloodsubBehaviour<TSubstream> {
|
pub struct FloodsubBehaviour<TSubstream> {
|
||||||
/// Events that need to be yielded to the outside when polling.
|
/// Events that need to be yielded to the outside when polling.
|
||||||
events: VecDeque<NetworkBehaviorAction<FloodsubRpc, FloodsubMessage>>,
|
events: VecDeque<NetworkBehaviourAction<FloodsubRpc, FloodsubMessage>>,
|
||||||
|
|
||||||
/// Peer id of the local node. Used for the source of the messages that we publish.
|
/// Peer id of the local node. Used for the source of the messages that we publish.
|
||||||
local_peer_id: PeerId,
|
local_peer_id: PeerId,
|
||||||
@ -81,7 +81,7 @@ impl<TSubstream> FloodsubBehaviour<TSubstream> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for peer in self.connected_peers.keys() {
|
for peer in self.connected_peers.keys() {
|
||||||
self.events.push_back(NetworkBehaviorAction::SendEvent {
|
self.events.push_back(NetworkBehaviourAction::SendEvent {
|
||||||
peer_id: peer.clone(),
|
peer_id: peer.clone(),
|
||||||
event: FloodsubRpc {
|
event: FloodsubRpc {
|
||||||
messages: Vec::new(),
|
messages: Vec::new(),
|
||||||
@ -112,7 +112,7 @@ impl<TSubstream> FloodsubBehaviour<TSubstream> {
|
|||||||
self.subscribed_topics.remove(pos);
|
self.subscribed_topics.remove(pos);
|
||||||
|
|
||||||
for peer in self.connected_peers.keys() {
|
for peer in self.connected_peers.keys() {
|
||||||
self.events.push_back(NetworkBehaviorAction::SendEvent {
|
self.events.push_back(NetworkBehaviourAction::SendEvent {
|
||||||
peer_id: peer.clone(),
|
peer_id: peer.clone(),
|
||||||
event: FloodsubRpc {
|
event: FloodsubRpc {
|
||||||
messages: Vec::new(),
|
messages: Vec::new(),
|
||||||
@ -161,7 +161,7 @@ impl<TSubstream> FloodsubBehaviour<TSubstream> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.events.push_back(NetworkBehaviorAction::SendEvent {
|
self.events.push_back(NetworkBehaviourAction::SendEvent {
|
||||||
peer_id: peer_id.clone(),
|
peer_id: peer_id.clone(),
|
||||||
event: FloodsubRpc {
|
event: FloodsubRpc {
|
||||||
subscriptions: Vec::new(),
|
subscriptions: Vec::new(),
|
||||||
@ -172,7 +172,7 @@ impl<TSubstream> FloodsubBehaviour<TSubstream> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<TSubstream> NetworkBehavior for FloodsubBehaviour<TSubstream>
|
impl<TSubstream> NetworkBehaviour for FloodsubBehaviour<TSubstream>
|
||||||
where
|
where
|
||||||
TSubstream: AsyncRead + AsyncWrite,
|
TSubstream: AsyncRead + AsyncWrite,
|
||||||
{
|
{
|
||||||
@ -186,7 +186,7 @@ where
|
|||||||
fn inject_connected(&mut self, id: PeerId, _: ConnectedPoint) {
|
fn inject_connected(&mut self, id: PeerId, _: ConnectedPoint) {
|
||||||
// We need to send our subscriptions to the newly-connected node.
|
// We need to send our subscriptions to the newly-connected node.
|
||||||
for topic in self.subscribed_topics.iter() {
|
for topic in self.subscribed_topics.iter() {
|
||||||
self.events.push_back(NetworkBehaviorAction::SendEvent {
|
self.events.push_back(NetworkBehaviourAction::SendEvent {
|
||||||
peer_id: id.clone(),
|
peer_id: id.clone(),
|
||||||
event: FloodsubRpc {
|
event: FloodsubRpc {
|
||||||
messages: Vec::new(),
|
messages: Vec::new(),
|
||||||
@ -242,7 +242,7 @@ where
|
|||||||
|
|
||||||
// Add the message to be dispatched to the user.
|
// Add the message to be dispatched to the user.
|
||||||
if self.subscribed_topics.iter().any(|t| message.topics.iter().any(|u| t.hash() == u)) {
|
if self.subscribed_topics.iter().any(|t| message.topics.iter().any(|u| t.hash() == u)) {
|
||||||
self.events.push_back(NetworkBehaviorAction::GenerateEvent(message.clone()));
|
self.events.push_back(NetworkBehaviourAction::GenerateEvent(message.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Propagate the message to everyone else who is subscribed to any of the topics.
|
// Propagate the message to everyone else who is subscribed to any of the topics.
|
||||||
@ -267,7 +267,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (peer_id, rpc) in rpcs_to_dispatch {
|
for (peer_id, rpc) in rpcs_to_dispatch {
|
||||||
self.events.push_back(NetworkBehaviorAction::SendEvent {
|
self.events.push_back(NetworkBehaviourAction::SendEvent {
|
||||||
peer_id,
|
peer_id,
|
||||||
event: rpc,
|
event: rpc,
|
||||||
});
|
});
|
||||||
@ -277,7 +277,7 @@ where
|
|||||||
fn poll(
|
fn poll(
|
||||||
&mut self,
|
&mut self,
|
||||||
) -> Async<
|
) -> Async<
|
||||||
NetworkBehaviorAction<
|
NetworkBehaviourAction<
|
||||||
<Self::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
<Self::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
||||||
Self::OutEvent,
|
Self::OutEvent,
|
||||||
>,
|
>,
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use libp2p_core::nodes::{ConnectedPoint, NetworkBehavior, NetworkBehaviorAction};
|
use libp2p_core::nodes::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||||
use libp2p_core::{protocols_handler::ProtocolsHandler, Multiaddr, PeerId};
|
use libp2p_core::{protocols_handler::ProtocolsHandler, Multiaddr, PeerId};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{collections::HashMap, io, marker::PhantomData};
|
use std::{collections::HashMap, io, marker::PhantomData};
|
||||||
@ -64,7 +64,7 @@ impl<TSubstream> IdentifyListen<TSubstream> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<TSubstream> NetworkBehavior for IdentifyListen<TSubstream>
|
impl<TSubstream> NetworkBehaviour for IdentifyListen<TSubstream>
|
||||||
where
|
where
|
||||||
TSubstream: AsyncRead + AsyncWrite + Send + Sync + 'static,
|
TSubstream: AsyncRead + AsyncWrite + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
@ -103,7 +103,7 @@ where
|
|||||||
fn poll(
|
fn poll(
|
||||||
&mut self,
|
&mut self,
|
||||||
) -> Async<
|
) -> Async<
|
||||||
NetworkBehaviorAction<
|
NetworkBehaviourAction<
|
||||||
<Self::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
<Self::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
||||||
Self::OutEvent,
|
Self::OutEvent,
|
||||||
>,
|
>,
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use libp2p_core::nodes::{ConnectedPoint, NetworkBehavior, NetworkBehaviorAction};
|
use libp2p_core::nodes::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||||
use libp2p_core::{protocols_handler::ProtocolsHandler, Multiaddr, PeerId};
|
use libp2p_core::{protocols_handler::ProtocolsHandler, Multiaddr, PeerId};
|
||||||
use std::{collections::VecDeque, marker::PhantomData};
|
use std::{collections::VecDeque, marker::PhantomData};
|
||||||
use tokio_io::{AsyncRead, AsyncWrite};
|
use tokio_io::{AsyncRead, AsyncWrite};
|
||||||
@ -44,7 +44,7 @@ impl<TSubstream> PeriodicIdentifyBehaviour<TSubstream> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<TSubstream> NetworkBehavior for PeriodicIdentifyBehaviour<TSubstream>
|
impl<TSubstream> NetworkBehaviour for PeriodicIdentifyBehaviour<TSubstream>
|
||||||
where
|
where
|
||||||
TSubstream: AsyncRead + AsyncWrite + Send + Sync + 'static,
|
TSubstream: AsyncRead + AsyncWrite + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
@ -80,13 +80,13 @@ where
|
|||||||
fn poll(
|
fn poll(
|
||||||
&mut self,
|
&mut self,
|
||||||
) -> Async<
|
) -> Async<
|
||||||
NetworkBehaviorAction<
|
NetworkBehaviourAction<
|
||||||
<Self::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
<Self::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
||||||
Self::OutEvent,
|
Self::OutEvent,
|
||||||
>,
|
>,
|
||||||
> {
|
> {
|
||||||
if let Some(event) = self.events.pop_front() {
|
if let Some(event) = self.events.pop_front() {
|
||||||
return Async::Ready(NetworkBehaviorAction::GenerateEvent(event));
|
return Async::Ready(NetworkBehaviourAction::GenerateEvent(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
Async::NotReady
|
Async::NotReady
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use libp2p_core::nodes::{ConnectedPoint, NetworkBehavior, NetworkBehaviorAction};
|
use libp2p_core::nodes::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||||
use libp2p_core::{protocols_handler::ProtocolsHandler, PeerId};
|
use libp2p_core::{protocols_handler::ProtocolsHandler, PeerId};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use tokio_io::{AsyncRead, AsyncWrite};
|
use tokio_io::{AsyncRead, AsyncWrite};
|
||||||
@ -48,7 +48,7 @@ impl<TSubstream> Default for PeriodicPingBehaviour<TSubstream> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<TSubstream> NetworkBehavior for PeriodicPingBehaviour<TSubstream>
|
impl<TSubstream> NetworkBehaviour for PeriodicPingBehaviour<TSubstream>
|
||||||
where
|
where
|
||||||
TSubstream: AsyncRead + AsyncWrite,
|
TSubstream: AsyncRead + AsyncWrite,
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ where
|
|||||||
fn poll(
|
fn poll(
|
||||||
&mut self,
|
&mut self,
|
||||||
) -> Async<
|
) -> Async<
|
||||||
NetworkBehaviorAction<
|
NetworkBehaviourAction<
|
||||||
<Self::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
<Self::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
||||||
Self::OutEvent,
|
Self::OutEvent,
|
||||||
>,
|
>,
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use libp2p_core::nodes::{ConnectedPoint, NetworkBehavior, NetworkBehaviorAction};
|
use libp2p_core::nodes::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||||
use libp2p_core::{protocols_handler::ProtocolsHandler, PeerId};
|
use libp2p_core::{protocols_handler::ProtocolsHandler, PeerId};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use tokio_io::{AsyncRead, AsyncWrite};
|
use tokio_io::{AsyncRead, AsyncWrite};
|
||||||
@ -48,7 +48,7 @@ impl<TSubstream> Default for PingListenBehaviour<TSubstream> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<TSubstream> NetworkBehavior for PingListenBehaviour<TSubstream>
|
impl<TSubstream> NetworkBehaviour for PingListenBehaviour<TSubstream>
|
||||||
where
|
where
|
||||||
TSubstream: AsyncRead + AsyncWrite,
|
TSubstream: AsyncRead + AsyncWrite,
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ where
|
|||||||
fn poll(
|
fn poll(
|
||||||
&mut self,
|
&mut self,
|
||||||
) -> Async<
|
) -> Async<
|
||||||
NetworkBehaviorAction<
|
NetworkBehaviourAction<
|
||||||
<Self::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
<Self::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
||||||
Self::OutEvent,
|
Self::OutEvent,
|
||||||
>,
|
>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user