Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor network #370

Merged
merged 9 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ serde = "1.0"
serde_derive = "1.0"
toml = "0.5"
log = "0.4"
futures = "0.1"
crossbeam-channel = "0.3"
config-tool = { package= "config", version = "0.9" }
ckb-util = { path = "util" }
Expand Down
14 changes: 8 additions & 6 deletions network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ fnv = "1.0"
serde = "1.0"
serde_derive = "1.0"
ckb-util = { path = "../util" }
stop-handler = { path = "../util/stop-handler" }
unsigned-varint = {git = "https://github.com/paritytech/unsigned-varint", features = ["codec"]}
log = "0.4.5"
bytes = "0.4.12"
tokio = "0.1.18"
futures = { version = "0.1.19", features = ["use_std"] }
futures = "0.1"
snap = "0.2"
p2p = { git = "https://github.com/nervosnetwork/p2p", rev="6c1f778914dae864d13c1d9110a08b46fb4d38fe", package="tentacle" }
secio = { git = "https://github.com/nervosnetwork/p2p", rev="6c1f778914dae864d13c1d9110a08b46fb4d38fe", package="tentacle-secio" }
p2p-ping = { git = "https://github.com/nervosnetwork/p2p", rev="6c1f778914dae864d13c1d9110a08b46fb4d38fe", package="tentacle-ping" }
p2p-discovery = { git = "https://github.com/nervosnetwork/p2p", rev="6c1f778914dae864d13c1d9110a08b46fb4d38fe", package="tentacle-discovery" }
p2p-identify = { git = "https://github.com/nervosnetwork/p2p", rev="6c1f778914dae864d13c1d9110a08b46fb4d38fe", package="tentacle-identify" }
crossbeam-channel = "0.3"
p2p = { git = "https://github.com/nervosnetwork/p2p", rev="fc6b46bae4d371c440c557a3736329a53d9f1e2e", package="tentacle" }
secio = { git = "https://github.com/nervosnetwork/p2p", rev="fc6b46bae4d371c440c557a3736329a53d9f1e2e", package="tentacle-secio" }
p2p-ping = { git = "https://github.com/nervosnetwork/p2p", rev="fc6b46bae4d371c440c557a3736329a53d9f1e2e", package="tentacle-ping" }
p2p-discovery = { git = "https://github.com/nervosnetwork/p2p", rev="fc6b46bae4d371c440c557a3736329a53d9f1e2e", package="tentacle-discovery" }
p2p-identify = { git = "https://github.com/nervosnetwork/p2p", rev="fc6b46bae4d371c440c557a3736329a53d9f1e2e", package="tentacle-identify" }
faketime = "0.2.0"
rusqlite = {version = "0.16.0", features = ["bundled"]}
lazy_static = "1.3.0"
Expand Down
File renamed without changes.
39 changes: 18 additions & 21 deletions network/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
#[macro_use]
pub extern crate futures;
mod behaviour;
mod config;
pub mod errors;
pub mod network;
mod network_config;
mod network_group;
mod network_service;
mod peer;
pub mod peer_store;
pub mod peers_registry;
pub mod protocol;
mod service;
mod protocols;

#[cfg(test)]
mod tests;

pub use crate::behaviour::Behaviour;
pub use crate::network::{Network, SessionInfo};
pub use crate::network_config::NetworkConfig;
pub use crate::network_service::NetworkService;
pub use crate::peer::{Peer, PeerIdentifyInfo};
pub use crate::peer_store::Score;
pub use crate::peers_registry::RegisterResult;
pub use crate::protocol::{
ckb::{CKBProtocol, Event as CKBEvent, Version as ProtocolVersion},
ckb_handler::{CKBProtocolContext, CKBProtocolHandler, Severity},
pub use crate::{
behaviour::Behaviour,
config::NetworkConfig,
errors::Error,
network::{NetworkController, NetworkService, NetworkState, SessionInfo},
peer::{Peer, PeerIdentifyInfo},
peer_store::Score,
peers_registry::RegisterResult,
protocols::{CKBProtocol, CKBProtocolContext, CKBProtocolHandler, ProtocolVersion},
};
pub use crate::service::timer_service::{Timer, TimerRegistry, TimerToken};
pub use errors::Error;
pub use p2p::{multiaddr, secio::PeerId, yamux::session::SessionType, ProtocolId};
// p2p internal expose
pub(crate) use p2p::{
context::{ServiceContext, SessionContext},
pub use p2p::{
context::{ProtocolContext, ProtocolContextMutRef, ServiceContext, SessionContext},
multiaddr,
secio::PeerId,
service::ServiceControl,
SessionId,
yamux::session::SessionType,
ProtocolId, SessionId,
};

// used in CKBProtocolContext
Expand Down
Loading