Move swarm and protocols handler into swarm crate. (#1188)

Move swarm and protocols handler into swarm crate.
This commit is contained in:
Toralf Wittner
2019-07-04 14:47:59 +02:00
committed by GitHub
parent ef9cb056b2
commit 68c36d87d3
45 changed files with 392 additions and 376 deletions

View File

@ -16,6 +16,7 @@ cuckoofilter = "0.3.2"
fnv = "1.0"
futures = "0.1"
libp2p-core = { version = "0.10.0", path = "../../core" }
libp2p-swarm = { version = "0.1.0", path = "../../swarm" }
protobuf = "2.3"
rand = "0.6"
smallvec = "0.6.5"

View File

@ -23,8 +23,14 @@ use crate::topic::{Topic, TopicHash};
use cuckoofilter::CuckooFilter;
use fnv::FnvHashSet;
use futures::prelude::*;
use libp2p_core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use libp2p_core::{protocols_handler::ProtocolsHandler, protocols_handler::OneShotHandler, Multiaddr, PeerId};
use libp2p_core::{ConnectedPoint, Multiaddr, PeerId};
use libp2p_swarm::{
NetworkBehaviour,
NetworkBehaviourAction,
PollParameters,
ProtocolsHandler,
OneShotHandler
};
use rand;
use smallvec::SmallVec;
use std::{collections::VecDeque, iter, marker::PhantomData};

View File

@ -14,6 +14,7 @@ bytes = "0.4"
fnv = "1"
futures = "0.1"
libp2p-core = { version = "0.10.0", path = "../../core" }
libp2p-swarm = { version = "0.1.0", path = "../../swarm" }
log = "0.4.1"
multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../../misc/multiaddr" }
parking_lot = "0.8"

View File

@ -22,9 +22,22 @@ use crate::listen_handler::IdentifyListenHandler;
use crate::periodic_id_handler::{PeriodicIdHandler, PeriodicIdHandlerEvent};
use crate::protocol::{IdentifyInfo, IdentifySender, IdentifySenderFuture};
use futures::prelude::*;
use libp2p_core::protocols_handler::{ProtocolsHandler, ProtocolsHandlerSelect, ProtocolsHandlerUpgrErr};
use libp2p_core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use libp2p_core::{Multiaddr, PeerId, PublicKey, either::EitherOutput, upgrade::Negotiated};
use libp2p_core::{
ConnectedPoint,
Multiaddr,
PeerId,
PublicKey,
either::EitherOutput,
upgrade::Negotiated
};
use libp2p_swarm::{
NetworkBehaviour,
NetworkBehaviourAction,
PollParameters,
ProtocolsHandler,
ProtocolsHandlerSelect,
ProtocolsHandlerUpgrErr
};
use smallvec::SmallVec;
use std::{collections::HashMap, collections::VecDeque, io};
use tokio_io::{AsyncRead, AsyncWrite};
@ -227,11 +240,11 @@ mod tests {
upgrade::{self, OutboundUpgradeExt, InboundUpgradeExt},
muxing::StreamMuxer,
Multiaddr,
Swarm,
Transport
};
use libp2p_tcp::TcpConfig;
use libp2p_secio::SecioConfig;
use libp2p_swarm::Swarm;
use libp2p_mplex::MplexConfig;
use rand::Rng;
use std::{fmt, io};

View File

@ -20,15 +20,13 @@
use crate::protocol::{IdentifySender, IdentifyProtocolConfig};
use futures::prelude::*;
use libp2p_core::{
protocols_handler::{
KeepAlive,
SubstreamProtocol,
ProtocolsHandler,
ProtocolsHandlerEvent,
ProtocolsHandlerUpgrErr
},
upgrade::{DeniedUpgrade, InboundUpgrade, OutboundUpgrade, Negotiated}
use libp2p_core::upgrade::{DeniedUpgrade, InboundUpgrade, OutboundUpgrade, Negotiated};
use libp2p_swarm::{
KeepAlive,
SubstreamProtocol,
ProtocolsHandler,
ProtocolsHandlerEvent,
ProtocolsHandlerUpgrErr
};
use smallvec::SmallVec;
use tokio_io::{AsyncRead, AsyncWrite};

View File

@ -20,15 +20,13 @@
use crate::protocol::{RemoteInfo, IdentifyProtocolConfig};
use futures::prelude::*;
use libp2p_core::{
protocols_handler::{
KeepAlive,
SubstreamProtocol,
ProtocolsHandler,
ProtocolsHandlerEvent,
ProtocolsHandlerUpgrErr
},
upgrade::{DeniedUpgrade, OutboundUpgrade}
use libp2p_core::upgrade::{DeniedUpgrade, OutboundUpgrade};
use libp2p_swarm::{
KeepAlive,
SubstreamProtocol,
ProtocolsHandler,
ProtocolsHandlerEvent,
ProtocolsHandlerUpgrErr
};
use std::{io, marker::PhantomData, time::Duration};
use tokio_io::{AsyncRead, AsyncWrite};

View File

@ -23,7 +23,8 @@ use crate::structs_proto;
use futures::{future::{self, FutureResult}, Async, AsyncSink, Future, Poll, Sink, Stream};
use futures::try_ready;
use libp2p_core::{
Multiaddr, PublicKey,
Multiaddr,
PublicKey,
upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo, Negotiated}
};
use log::{debug, trace};

View File

@ -19,6 +19,7 @@ either = "1.5"
fnv = "1.0"
futures = "0.1"
libp2p-core = { version = "0.10.0", path = "../../core" }
libp2p-swarm = { version = "0.1.0", path = "../../swarm" }
log = "0.4"
multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../../misc/multiaddr" }
multihash = { package = "parity-multihash", version = "0.1.0", path = "../../misc/multihash" }

View File

@ -27,8 +27,8 @@ use crate::query::{Query, QueryId, QueryPool, QueryConfig, QueryPoolState};
use crate::record::{MemoryRecordStorage, RecordStore, Record, RecordStorageError};
use fnv::{FnvHashMap, FnvHashSet};
use futures::{prelude::*, stream};
use libp2p_core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use libp2p_core::{protocols_handler::ProtocolsHandler, Multiaddr, PeerId};
use libp2p_core::{ConnectedPoint, Multiaddr, PeerId};
use libp2p_swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters, ProtocolsHandler};
use multihash::Multihash;
use smallvec::SmallVec;
use std::{borrow::Cow, error, marker::PhantomData, time::Duration, num::NonZeroU8};

View File

@ -25,7 +25,7 @@ use super::*;
use crate::kbucket::Distance;
use futures::future;
use libp2p_core::{
Swarm,
PeerId,
Transport,
identity,
transport::{MemoryTransport, boxed::Boxed},
@ -35,6 +35,7 @@ use libp2p_core::{
upgrade,
};
use libp2p_secio::SecioConfig;
use libp2p_swarm::Swarm;
use libp2p_yamux as yamux;
use rand::{Rng, random, thread_rng};
use std::{collections::HashSet, iter::FromIterator, io, num::NonZeroU8, u64};

View File

@ -24,14 +24,17 @@ use crate::protocol::{
};
use crate::record::Record;
use futures::prelude::*;
use libp2p_core::protocols_handler::{
use libp2p_swarm::{
KeepAlive,
SubstreamProtocol,
ProtocolsHandler,
ProtocolsHandlerEvent,
ProtocolsHandlerUpgrErr
};
use libp2p_core::{upgrade, either::EitherOutput, InboundUpgrade, OutboundUpgrade, upgrade::Negotiated};
use libp2p_core::{
either::EitherOutput,
upgrade::{self, InboundUpgrade, OutboundUpgrade, Negotiated}
};
use multihash::Multihash;
use std::{borrow::Cow, error, fmt, io, time::Duration};
use tokio_io::{AsyncRead, AsyncWrite};

View File

@ -13,6 +13,7 @@ categories = ["network-programming", "asynchronous"]
arrayvec = "0.4"
bytes = "0.4"
libp2p-core = { version = "0.10.0", path = "../../core" }
libp2p-swarm = { version = "0.1.0", path = "../../swarm" }
log = "0.4.1"
multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../../misc/multiaddr" }
futures = "0.1"

View File

@ -20,12 +20,12 @@
use crate::protocol;
use futures::prelude::*;
use libp2p_core::ProtocolsHandlerEvent;
use libp2p_core::protocols_handler::{
use libp2p_swarm::{
KeepAlive,
SubstreamProtocol,
ProtocolsHandler,
ProtocolsHandlerUpgrErr,
ProtocolsHandlerEvent
};
use std::{error::Error, io, fmt, num::NonZeroU32, time::Duration};
use std::collections::VecDeque;

View File

@ -48,8 +48,8 @@ pub use handler::{PingConfig, PingResult, PingSuccess, PingFailure};
use handler::PingHandler;
use futures::prelude::*;
use libp2p_core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use libp2p_core::{Multiaddr, PeerId};
use libp2p_core::{ConnectedPoint, Multiaddr, PeerId};
use libp2p_swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use std::collections::VecDeque;
use std::marker::PhantomData;
use tokio_io::{AsyncRead, AsyncWrite};

View File

@ -23,7 +23,6 @@
use libp2p_core::{
Multiaddr,
PeerId,
Swarm,
identity,
muxing::StreamMuxer,
upgrade::{self, OutboundUpgradeExt, InboundUpgradeExt},
@ -32,6 +31,7 @@ use libp2p_core::{
use libp2p_ping::*;
use libp2p_yamux as yamux;
use libp2p_secio::SecioConfig;
use libp2p_swarm::Swarm;
use libp2p_tcp::TcpConfig;
use futures::{future, prelude::*};
use std::{fmt, io, time::Duration, sync::mpsc::sync_channel};