mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-20 13:26:34 +00:00
Move the Swarm in its own module (#681)
This commit is contained in:
@ -210,16 +210,17 @@ pub mod either;
|
||||
pub mod muxing;
|
||||
pub mod nodes;
|
||||
pub mod protocols_handler;
|
||||
pub mod swarm;
|
||||
pub mod topology;
|
||||
pub mod transport;
|
||||
pub mod upgrade;
|
||||
|
||||
pub use self::multiaddr::Multiaddr;
|
||||
pub use self::muxing::StreamMuxer;
|
||||
pub use self::nodes::Swarm;
|
||||
pub use self::peer_id::PeerId;
|
||||
pub use self::protocols_handler::{ProtocolsHandler, ProtocolsHandlerEvent};
|
||||
pub use self::public_key::PublicKey;
|
||||
pub use self::swarm::Swarm;
|
||||
pub use self::transport::Transport;
|
||||
pub use self::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo, UpgradeError};
|
||||
|
||||
|
@ -24,9 +24,7 @@ pub mod handled_node_tasks;
|
||||
pub mod listeners;
|
||||
pub mod node;
|
||||
pub mod raw_swarm;
|
||||
pub mod swarm;
|
||||
|
||||
pub use self::node::Substream;
|
||||
pub use self::handled_node::{NodeHandlerEvent, NodeHandlerEndpoint};
|
||||
pub use self::raw_swarm::{ConnectedPoint, Peer, RawSwarm, RawSwarmEvent};
|
||||
pub use self::swarm::{Swarm, NetworkBehaviour, NetworkBehaviourAction};
|
||||
|
@ -24,7 +24,7 @@ use crate::{
|
||||
nodes::{
|
||||
handled_node::NodeHandler,
|
||||
node::Substream,
|
||||
raw_swarm::{RawSwarm, RawSwarmEvent, ConnectedPoint}
|
||||
raw_swarm::{RawSwarm, RawSwarmEvent}
|
||||
},
|
||||
protocols_handler::{NodeHandlerWrapper, ProtocolsHandler},
|
||||
topology::Topology
|
||||
@ -32,6 +32,8 @@ use crate::{
|
||||
use futures::prelude::*;
|
||||
use std::{fmt, io, ops::{Deref, DerefMut}};
|
||||
|
||||
pub use crate::nodes::raw_swarm::ConnectedPoint;
|
||||
|
||||
/// Contains the state of the network, plus the way it should behave.
|
||||
pub struct Swarm<TTransport, TBehaviour, TTopology>
|
||||
where TTransport: Transport,
|
@ -49,13 +49,13 @@ fn build(ast: &DeriveInput) -> TokenStream {
|
||||
fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||
let name = &ast.ident;
|
||||
let (_, ty_generics, where_clause) = ast.generics.split_for_impl();
|
||||
let trait_to_impl = quote!{::libp2p::core::nodes::swarm::NetworkBehaviour};
|
||||
let trait_to_impl = quote!{::libp2p::core::swarm::NetworkBehaviour};
|
||||
let either_ident = quote!{::libp2p::core::either::EitherOutput};
|
||||
let network_behaviour_action = quote!{::libp2p::core::nodes::swarm::NetworkBehaviourAction};
|
||||
let network_behaviour_action = quote!{::libp2p::core::swarm::NetworkBehaviourAction};
|
||||
let protocols_handler = quote!{::libp2p::core::protocols_handler::ProtocolsHandler};
|
||||
let proto_select_ident = quote!{::libp2p::core::protocols_handler::ProtocolsHandlerSelect};
|
||||
let peer_id = quote!{::libp2p::core::PeerId};
|
||||
let connected_point = quote!{::libp2p::core::nodes::ConnectedPoint};
|
||||
let connected_point = quote!{::libp2p::core::swarm::ConnectedPoint};
|
||||
|
||||
// Name of the type parameter that represents the substream.
|
||||
let substream_generic = {
|
||||
|
@ -74,7 +74,7 @@ fn event_handler() {
|
||||
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
|
||||
// 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::NetworkBehaviour>::OutEvent) {
|
||||
fn foo(&mut self, ev: <libp2p::identify::PeriodicIdentifyBehaviour<TSubstream> as libp2p::core::swarm::NetworkBehaviour>::OutEvent) {
|
||||
let libp2p::identify::PeriodicIdentifyBehaviourEvent::Identified { .. } = ev;
|
||||
}
|
||||
}
|
||||
@ -91,7 +91,7 @@ fn custom_polling() {
|
||||
}
|
||||
|
||||
impl<TSubstream> Foo<TSubstream> {
|
||||
fn foo<T>(&mut self) -> libp2p::futures::Async<libp2p::core::nodes::NetworkBehaviourAction<T, ()>> { libp2p::futures::Async::NotReady }
|
||||
fn foo<T>(&mut self) -> libp2p::futures::Async<libp2p::core::swarm::NetworkBehaviourAction<T, ()>> { libp2p::futures::Async::NotReady }
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,6 +117,6 @@ fn custom_event_and_polling() {
|
||||
}
|
||||
|
||||
impl<TSubstream> Foo<TSubstream> {
|
||||
fn foo<T>(&mut self) -> libp2p::futures::Async<libp2p::core::nodes::NetworkBehaviourAction<T, String>> { libp2p::futures::Async::NotReady }
|
||||
fn foo<T>(&mut self) -> libp2p::futures::Async<libp2p::core::swarm::NetworkBehaviourAction<T, String>> { libp2p::futures::Async::NotReady }
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
use cuckoofilter::CuckooFilter;
|
||||
use futures::prelude::*;
|
||||
use handler::FloodsubHandler;
|
||||
use libp2p_core::nodes::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||
use libp2p_core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||
use libp2p_core::{protocols_handler::ProtocolsHandler, PeerId};
|
||||
use protocol::{FloodsubMessage, FloodsubRpc, FloodsubSubscription, FloodsubSubscriptionAction};
|
||||
use rand;
|
||||
|
@ -19,7 +19,7 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::nodes::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||
use libp2p_core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||
use libp2p_core::{protocols_handler::ProtocolsHandler, Multiaddr, PeerId};
|
||||
use smallvec::SmallVec;
|
||||
use std::collections::HashMap;
|
||||
|
@ -19,7 +19,7 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::nodes::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||
use libp2p_core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||
use libp2p_core::{protocols_handler::ProtocolsHandler, Multiaddr, PeerId};
|
||||
use std::{collections::VecDeque, marker::PhantomData};
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
|
@ -19,7 +19,7 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::nodes::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||
use libp2p_core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||
use libp2p_core::{protocols_handler::ProtocolsHandler, PeerId};
|
||||
use std::marker::PhantomData;
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
|
@ -19,7 +19,7 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::nodes::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||
use libp2p_core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
|
||||
use libp2p_core::{protocols_handler::ProtocolsHandler, PeerId};
|
||||
use std::marker::PhantomData;
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
|
Reference in New Issue
Block a user