From ee41fa6f30fe275977265c7e139b4841ab47c725 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 22 May 2018 06:34:01 +0200 Subject: [PATCH] Move connection_filter to the network crate (#8674) --- Cargo.lock | 1 + ethcore/node_filter/Cargo.toml | 1 + ethcore/node_filter/src/lib.rs | 6 ++++-- ethcore/sync/src/api.rs | 5 +++-- ethcore/sync/src/lib.rs | 4 ++-- util/network-devp2p/src/host.rs | 2 +- util/network-devp2p/src/lib.rs | 2 -- util/network-devp2p/src/service.rs | 2 +- util/{network-devp2p => network}/src/connection_filter.rs | 0 util/network/src/lib.rs | 2 ++ 10 files changed, 15 insertions(+), 10 deletions(-) rename util/{network-devp2p => network}/src/connection_filter.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index e2fa0a9db..646bc9064 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1805,6 +1805,7 @@ dependencies = [ "ethabi-derive 5.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.12.0", "ethcore-io 1.12.0", + "ethcore-network 1.12.0", "ethcore-network-devp2p 1.12.0", "ethereum-types 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.0", diff --git a/ethcore/node_filter/Cargo.toml b/ethcore/node_filter/Cargo.toml index 25b5ec59f..0d204e29f 100644 --- a/ethcore/node_filter/Cargo.toml +++ b/ethcore/node_filter/Cargo.toml @@ -8,6 +8,7 @@ authors = ["Parity Technologies "] [dependencies] ethcore = { path = ".."} +ethcore-network = { path = "../../util/network" } ethcore-network-devp2p = { path = "../../util/network-devp2p" } ethereum-types = "0.3" log = "0.3" diff --git a/ethcore/node_filter/src/lib.rs b/ethcore/node_filter/src/lib.rs index 715b7ae3e..c731ad356 100644 --- a/ethcore/node_filter/src/lib.rs +++ b/ethcore/node_filter/src/lib.rs @@ -18,7 +18,8 @@ extern crate ethabi; extern crate ethcore; -extern crate ethcore_network_devp2p as network; +extern crate ethcore_network as network; +extern crate ethcore_network_devp2p as devp2p; extern crate ethereum_types; extern crate lru_cache; extern crate parking_lot; @@ -43,7 +44,8 @@ use parking_lot::Mutex; use ethcore::client::{BlockChainClient, BlockId}; use ethereum_types::{H256, Address}; -use network::{NodeId, ConnectionFilter, ConnectionDirection}; +use network::{ConnectionFilter, ConnectionDirection}; +use devp2p::NodeId; use_contract!(peer_set, "PeerSet", "res/peer_set.json"); diff --git a/ethcore/sync/src/api.rs b/ethcore/sync/src/api.rs index e901528e4..56ea8526e 100644 --- a/ethcore/sync/src/api.rs +++ b/ethcore/sync/src/api.rs @@ -19,9 +19,10 @@ use std::collections::{HashMap, BTreeMap}; use std::io; use std::time::Duration; use bytes::Bytes; -use devp2p::{NetworkService, ConnectionFilter}; +use devp2p::NetworkService; use network::{NetworkProtocolHandler, NetworkContext, HostInfo, PeerId, ProtocolId, - NetworkConfiguration as BasicNetworkConfiguration, NonReservedPeerMode, Error, ErrorKind}; + NetworkConfiguration as BasicNetworkConfiguration, NonReservedPeerMode, Error, ErrorKind, + ConnectionFilter}; use ethereum_types::{H256, H512, U256}; use io::{TimerToken}; use ethcore::ethstore::ethkey::Secret; diff --git a/ethcore/sync/src/lib.rs b/ethcore/sync/src/lib.rs index 3eb2e8332..c00ea5e44 100644 --- a/ethcore/sync/src/lib.rs +++ b/ethcore/sync/src/lib.rs @@ -74,6 +74,6 @@ mod api; pub use api::*; pub use chain::{SyncStatus, SyncState}; -pub use devp2p::{validate_node_url, ConnectionFilter, ConnectionDirection}; -pub use network::{NonReservedPeerMode, Error, ErrorKind}; +pub use devp2p::validate_node_url; +pub use network::{NonReservedPeerMode, Error, ErrorKind, ConnectionFilter, ConnectionDirection}; pub use private_tx::{PrivateTxHandler, NoopPrivateTxHandler, SimplePrivateTxHandler}; diff --git a/util/network-devp2p/src/host.rs b/util/network-devp2p/src/host.rs index 5ccab2e4d..3ab7b7f84 100644 --- a/util/network-devp2p/src/host.rs +++ b/util/network-devp2p/src/host.rs @@ -45,7 +45,7 @@ use discovery::{Discovery, TableUpdates, NodeEntry}; use ip_utils::{map_external_address, select_public_address}; use path::restrict_permissions_owner; use parking_lot::{Mutex, RwLock}; -use connection_filter::{ConnectionFilter, ConnectionDirection}; +use network::{ConnectionFilter, ConnectionDirection}; type Slab = ::slab::Slab; diff --git a/util/network-devp2p/src/lib.rs b/util/network-devp2p/src/lib.rs index e5bb95f22..244997a65 100644 --- a/util/network-devp2p/src/lib.rs +++ b/util/network-devp2p/src/lib.rs @@ -106,10 +106,8 @@ mod discovery; mod service; mod node_table; mod ip_utils; -mod connection_filter; pub use service::NetworkService; -pub use connection_filter::{ConnectionFilter, ConnectionDirection}; pub use host::NetworkContext; pub use io::TimerToken; diff --git a/util/network-devp2p/src/service.rs b/util/network-devp2p/src/service.rs index 10a1e9abc..3ac1ec7f7 100644 --- a/util/network-devp2p/src/service.rs +++ b/util/network-devp2p/src/service.rs @@ -21,7 +21,7 @@ use io::*; use parking_lot::RwLock; use std::sync::Arc; use ansi_term::Colour; -use connection_filter::ConnectionFilter; +use network::ConnectionFilter; struct HostHandler { public_url: RwLock> diff --git a/util/network-devp2p/src/connection_filter.rs b/util/network/src/connection_filter.rs similarity index 100% rename from util/network-devp2p/src/connection_filter.rs rename to util/network/src/connection_filter.rs diff --git a/util/network/src/lib.rs b/util/network/src/lib.rs index d16403cd3..f3012e4c3 100644 --- a/util/network/src/lib.rs +++ b/util/network/src/lib.rs @@ -27,8 +27,10 @@ extern crate snappy; #[macro_use] extern crate error_chain; +mod connection_filter; mod error; +pub use connection_filter::{ConnectionFilter, ConnectionDirection}; pub use io::TimerToken; pub use error::{Error, ErrorKind, DisconnectReason};