mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-28 17:21:34 +00:00
Behavior -> Behaviour (#650)
This commit is contained in:
@ -21,7 +21,7 @@
|
||||
use cuckoofilter::CuckooFilter;
|
||||
use futures::prelude::*;
|
||||
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 protocol::{FloodsubMessage, FloodsubRpc, FloodsubSubscription, FloodsubSubscriptionAction};
|
||||
use rand;
|
||||
@ -35,7 +35,7 @@ use topic::{Topic, TopicHash};
|
||||
/// about them.
|
||||
pub struct FloodsubBehaviour<TSubstream> {
|
||||
/// 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.
|
||||
local_peer_id: PeerId,
|
||||
@ -81,7 +81,7 @@ impl<TSubstream> FloodsubBehaviour<TSubstream> {
|
||||
}
|
||||
|
||||
for peer in self.connected_peers.keys() {
|
||||
self.events.push_back(NetworkBehaviorAction::SendEvent {
|
||||
self.events.push_back(NetworkBehaviourAction::SendEvent {
|
||||
peer_id: peer.clone(),
|
||||
event: FloodsubRpc {
|
||||
messages: Vec::new(),
|
||||
@ -112,7 +112,7 @@ impl<TSubstream> FloodsubBehaviour<TSubstream> {
|
||||
self.subscribed_topics.remove(pos);
|
||||
|
||||
for peer in self.connected_peers.keys() {
|
||||
self.events.push_back(NetworkBehaviorAction::SendEvent {
|
||||
self.events.push_back(NetworkBehaviourAction::SendEvent {
|
||||
peer_id: peer.clone(),
|
||||
event: FloodsubRpc {
|
||||
messages: Vec::new(),
|
||||
@ -161,7 +161,7 @@ impl<TSubstream> FloodsubBehaviour<TSubstream> {
|
||||
continue;
|
||||
}
|
||||
|
||||
self.events.push_back(NetworkBehaviorAction::SendEvent {
|
||||
self.events.push_back(NetworkBehaviourAction::SendEvent {
|
||||
peer_id: peer_id.clone(),
|
||||
event: FloodsubRpc {
|
||||
subscriptions: Vec::new(),
|
||||
@ -172,7 +172,7 @@ impl<TSubstream> FloodsubBehaviour<TSubstream> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<TSubstream> NetworkBehavior for FloodsubBehaviour<TSubstream>
|
||||
impl<TSubstream> NetworkBehaviour for FloodsubBehaviour<TSubstream>
|
||||
where
|
||||
TSubstream: AsyncRead + AsyncWrite,
|
||||
{
|
||||
@ -186,7 +186,7 @@ where
|
||||
fn inject_connected(&mut self, id: PeerId, _: ConnectedPoint) {
|
||||
// We need to send our subscriptions to the newly-connected node.
|
||||
for topic in self.subscribed_topics.iter() {
|
||||
self.events.push_back(NetworkBehaviorAction::SendEvent {
|
||||
self.events.push_back(NetworkBehaviourAction::SendEvent {
|
||||
peer_id: id.clone(),
|
||||
event: FloodsubRpc {
|
||||
messages: Vec::new(),
|
||||
@ -242,7 +242,7 @@ where
|
||||
|
||||
// Add the message to be dispatched to the user.
|
||||
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.
|
||||
@ -267,7 +267,7 @@ where
|
||||
}
|
||||
|
||||
for (peer_id, rpc) in rpcs_to_dispatch {
|
||||
self.events.push_back(NetworkBehaviorAction::SendEvent {
|
||||
self.events.push_back(NetworkBehaviourAction::SendEvent {
|
||||
peer_id,
|
||||
event: rpc,
|
||||
});
|
||||
@ -277,7 +277,7 @@ where
|
||||
fn poll(
|
||||
&mut self,
|
||||
) -> Async<
|
||||
NetworkBehaviorAction<
|
||||
NetworkBehaviourAction<
|
||||
<Self::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
||||
Self::OutEvent,
|
||||
>,
|
||||
|
Reference in New Issue
Block a user