Rename PeerHandshake -> peer::Handshake

This commit is contained in:
Henry de Valence 2019-11-27 11:42:59 -08:00 committed by Deirdre Connolly
parent 9ff0fd90dc
commit 778e49b127
5 changed files with 14 additions and 14 deletions

View File

@ -68,5 +68,5 @@ pub mod types {
/// This will be removed when we finish encapsulation
pub mod should_be_private {
pub use crate::{peer::PeerHandshake, timestamp_collector::TimestampCollector};
pub use crate::{peer::Handshake, timestamp_collector::TimestampCollector};
}

View File

@ -14,5 +14,5 @@ mod server;
pub use client::Client;
pub use connector::PeerConnector;
pub use error::{HandshakeError, PeerError, SharedPeerError};
pub use handshake::PeerHandshake;
pub use handshake::Handshake;
pub use server::Server;

View File

@ -9,13 +9,13 @@ use tower::{discover::Change, Service, ServiceExt};
use crate::{BoxedStdError, Request, Response};
use super::{HandshakeError, Client, PeerHandshake};
use super::{HandshakeError, Client, Handshake};
/// A wrapper around [`PeerHandshake`] that opens a TCP connection before
/// A wrapper around [`peer::Handshake`] that opens a TCP connection before
/// forwarding to the inner handshake service. Writing this as its own
/// [`tower::Service`] lets us apply unified timeout policies, etc.
pub struct PeerConnector<S> {
handshaker: PeerHandshake<S>,
handshaker: Handshake<S>,
}
impl<S: Clone> Clone for PeerConnector<S> {
@ -27,7 +27,7 @@ impl<S: Clone> Clone for PeerConnector<S> {
}
impl<S> PeerConnector<S> {
pub fn new(handshaker: PeerHandshake<S>) -> Self {
pub fn new(handshaker: Handshake<S>) -> Self {
Self { handshaker }
}
}

View File

@ -29,16 +29,16 @@ use super::{error::ErrorSlot, HandshakeError, Client, Server};
/// A [`Service`] that handshakes with a remote peer and constructs a
/// client/server pair.
pub struct PeerHandshake<S> {
pub struct Handshake<S> {
config: Config,
internal_service: S,
timestamp_collector: mpsc::Sender<MetaAddr>,
nonces: Arc<Mutex<HashSet<Nonce>>>,
}
impl<S: Clone> Clone for PeerHandshake<S> {
impl<S: Clone> Clone for Handshake<S> {
fn clone(&self) -> Self {
Self {
Handshake {
config: self.config.clone(),
internal_service: self.internal_service.clone(),
timestamp_collector: self.timestamp_collector.clone(),
@ -47,7 +47,7 @@ impl<S: Clone> Clone for PeerHandshake<S> {
}
}
impl<S> PeerHandshake<S>
impl<S> Handshake<S>
where
S: Service<Request, Response = Response, Error = BoxedStdError> + Clone + Send + 'static,
S::Future: Send,
@ -63,7 +63,7 @@ where
// Builder2, ..., with Builder1::with_config() -> Builder2;
// Builder2::with_internal_service() -> ... or use Options in a single
// Builder type or use the derive_builder crate.
PeerHandshake {
Handshake {
config,
internal_service,
timestamp_collector,
@ -72,7 +72,7 @@ where
}
}
impl<S> Service<(TcpStream, SocketAddr)> for PeerHandshake<S>
impl<S> Service<(TcpStream, SocketAddr)> for Handshake<S>
where
S: Service<Request, Response = Response, Error = BoxedStdError> + Clone + Send + 'static,
S::Future: Send,

View File

@ -26,7 +26,7 @@ use tower_load::{peak_ewma::PeakEwmaDiscover, NoInstrument};
use crate::{
peer,
peer::{PeerConnector, PeerHandshake},
peer::{PeerConnector},
timestamp_collector::TimestampCollector,
AddressBook, BoxedStdError, Config, Request, Response,
};
@ -64,7 +64,7 @@ where
let (listener, connector) = {
use tower::timeout::TimeoutLayer;
let hs_timeout = TimeoutLayer::new(config.handshake_timeout);
let hs = PeerHandshake::new(config.clone(), inbound_service, timestamp_collector);
let hs = peer::Handshake::new(config.clone(), inbound_service, timestamp_collector);
(
hs_timeout.layer(hs.clone()),
hs_timeout.layer(PeerConnector::new(hs)),