Skip to content

Commit

Permalink
minor network API cleanup (#7589)
Browse files Browse the repository at this point in the history
Removed bunch of type reexports which are not used outside of near-network.
  • Loading branch information
pompon0 authored and nikurt committed Nov 9, 2022
1 parent ad4a363 commit 3c8a852
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion chain/network/src/network_protocol/testonly.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;

use crate::config;
use crate::types::{AccountKeys, ChainInfo, Handshake, RoutingTableUpdate};
use crate::types::{AccountKeys, ChainInfo};
use near_crypto::{InMemorySigner, KeyType, SecretKey};
use near_network_primitives::time;
use near_network_primitives::types::{
Expand Down
1 change: 0 additions & 1 deletion chain/network/src/network_protocol/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use super::*;
use crate::network_protocol::testonly as data;
use crate::network_protocol::Encoding;
use crate::testonly::make_rng;
use crate::types::{HandshakeFailureReason, PeerMessage};
use anyhow::{bail, Context as _};
use near_network_primitives::time;
use near_network_primitives::types::{
Expand Down
5 changes: 2 additions & 3 deletions chain/network/src/peer/peer_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::accounts_data;
use crate::concurrency::atomic_cell::AtomicCell;
use crate::concurrency::demux;
use crate::network_protocol::{Encoding, ParsePeerMessageError, SyncAccountsData};
use crate::network_protocol::{Handshake, HandshakeFailureReason, PeerMessage};
use crate::peer::stream;
use crate::peer::tracker::Tracker;
use crate::peer_manager::connection;
Expand All @@ -14,9 +15,7 @@ use crate::private_actix::{
};
use crate::sink::Sink;
use crate::stats::metrics;
use crate::types::{
Handshake, HandshakeFailureReason, NetworkClientMessages, NetworkClientResponses, PeerMessage,
};
use crate::types::{NetworkClientMessages, NetworkClientResponses};
use actix::{
Actor, ActorContext, ActorFutureExt, AsyncContext, Context, ContextFutureSpawner, Handler,
Running, WrapFuture,
Expand Down
2 changes: 1 addition & 1 deletion chain/network/src/peer/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::broadcast;
use crate::concurrency::demux;
use crate::config::NetworkConfig;
use crate::network_protocol::testonly as data;
use crate::network_protocol::{PeerMessage, RoutingTableUpdate};
use crate::peer::peer_actor::{PeerActor, StreamConfig};
use crate::peer_manager::network_state::NetworkState;
use crate::peer_manager::peer_manager_actor;
Expand All @@ -11,7 +12,6 @@ use crate::routing::routing_table_view::RoutingTableView;
use crate::store;
use crate::testonly::actix::ActixSystem;
use crate::testonly::fake_client;
use crate::types::{PeerMessage, RoutingTableUpdate};
use actix::{Actor, Context, Handler};
use near_crypto::{InMemorySigner, Signature};
use near_network_primitives::types::{
Expand Down
2 changes: 1 addition & 1 deletion chain/network/src/peer/tests/communication.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::network_protocol::testonly as data;
use crate::network_protocol::Encoding;
use crate::network_protocol::{Handshake, HandshakeFailureReason, PeerMessage};
use crate::peer::testonly::{Event, PeerConfig, PeerHandle};
use crate::peer_manager::peer_manager_actor::Event as PME;
use crate::testonly::fake_client::Event as CE;
use crate::testonly::make_rng;
use crate::testonly::stream::Stream;
use crate::types::{Handshake, HandshakeFailureReason, PeerMessage};
use anyhow::Context as _;
use assert_matches::assert_matches;
use near_network_primitives::time;
Expand Down
3 changes: 2 additions & 1 deletion chain/network/src/peer_manager/network_state.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use crate::accounts_data;
use crate::concurrency::demux;
use crate::config;
use crate::network_protocol::PeerMessage;
use crate::peer::peer_actor::{PeerActor, StreamConfig};
use crate::peer_manager::connection;
use crate::private_actix::PeerToManagerMsg;
use crate::routing::routing_table_view::RoutingTableView;
use crate::stats::metrics;
use crate::types::{ChainInfo, NetworkClientMessages, PeerMessage};
use crate::types::{ChainInfo, NetworkClientMessages};
use actix::Recipient;
use arc_swap::ArcSwap;
use near_network_primitives::time;
Expand Down
4 changes: 2 additions & 2 deletions chain/network/src/peer_manager/peer_manager_actor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::config;
use crate::network_protocol::{AccountData, SyncAccountsData};
use crate::network_protocol::{AccountData, PeerMessage, RoutingTableUpdate, SyncAccountsData};
use crate::peer_manager::connection;
use crate::peer_manager::network_state::NetworkState;
use crate::peer_manager::peer_store::PeerStore;
Expand All @@ -16,7 +16,7 @@ use crate::store;
use crate::types::{
ConnectedPeerInfo, FullPeerInfo, GetNetworkInfo, NetworkClientMessages, NetworkInfo,
NetworkRequests, NetworkResponses, PeerManagerMessageRequest, PeerManagerMessageResponse,
PeerMessage, RoutingTableUpdate, SetChainInfo,
SetChainInfo,
};
use actix::{
Actor, ActorFutureExt, Addr, Arbiter, AsyncContext, Context, ContextFutureSpawner, Handler,
Expand Down
2 changes: 1 addition & 1 deletion chain/network/src/peer_manager/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use crate::concurrency::demux;
use crate::config;
use crate::network_protocol::testonly as data;
use crate::network_protocol::{Encoding, PeerAddr, SyncAccountsData};
use crate::network_protocol::{PeerMessage, RoutingTableUpdate};
use crate::peer;
use crate::peer_manager;
use crate::peer_manager::network_state::LIMIT_PENDING_PEERS;
use crate::peer_manager::peer_manager_actor::Event as PME;
use crate::peer_manager::testonly::{Event, NormalAccountData};
use crate::testonly::{assert_is_superset, make_rng, AsSet as _};
use crate::types::{PeerMessage, RoutingTableUpdate};
use itertools::Itertools;
use near_network_primitives::time;
use near_network_primitives::types::{Ping, RoutedMessageBody, EDGE_MIN_TIMESTAMP_NONCE};
Expand Down
6 changes: 2 additions & 4 deletions chain/network/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/// Type that belong to the network protocol.
pub use crate::network_protocol::{
Encoding, Handshake, HandshakeFailureReason, ParsePeerMessageError, PeerMessage,
RoutingTableUpdate, SignedAccountData,
};
use crate::network_protocol::SignedAccountData;
use crate::routing::routing_table_view::RoutingTableInfo;
use futures::future::BoxFuture;
use futures::FutureExt;
Expand Down Expand Up @@ -453,6 +450,7 @@ impl<M: actix::Message, T: MsgRecipient<M>> MsgRecipient<M> for NetworkRecipient
#[cfg(test)]
mod tests {
use super::*;
use crate::network_protocol::{Handshake, HandshakeFailureReason, RoutingTableUpdate};

// NOTE: this has it's counterpart in `near_network_primitives::types::tests`
const ALLOWED_SIZE: usize = 1 << 20;
Expand Down

0 comments on commit 3c8a852

Please sign in to comment.