From 741f7c96519ea8115e8d1d9c2d77797574c1712e Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Mon, 16 Jan 2023 17:03:50 +0100 Subject: [PATCH] node: Rename `Transport` to `Wire` Signed-off-by: Alexis Sellier --- radicle-node/src/client.rs | 8 ++++---- radicle-node/src/tests/e2e.rs | 4 ++-- radicle-node/src/wire.rs | 10 ++-------- .../src/wire/{transport.rs => protocol.rs} | 17 +++++++++++------ 4 files changed, 19 insertions(+), 20 deletions(-) rename radicle-node/src/wire/{transport.rs => protocol.rs} (97%) diff --git a/radicle-node/src/client.rs b/radicle-node/src/client.rs index a5b996d8..b1012c24 100644 --- a/radicle-node/src/client.rs +++ b/radicle-node/src/client.rs @@ -12,7 +12,7 @@ use crate::control; use crate::crypto::Signature; use crate::node::NodeId; use crate::service::{routing, tracking}; -use crate::wire::Transport; +use crate::wire::Wire; use crate::worker::{WorkerPool, WorkerReq}; use crate::{crypto, profile, service, LocalTime}; @@ -54,9 +54,9 @@ pub enum Error { /// Holds join handles to the client threads, as well as a client handle. pub struct Runtime + Clone> { pub id: NodeId, - pub handle: Handle>, + pub handle: Handle>, pub control: thread::JoinHandle>, - pub reactor: Reactor>, + pub reactor: Reactor>, pub pool: WorkerPool, pub local_addrs: Vec, } @@ -117,7 +117,7 @@ impl + Clone + 'static> worker_recv, id.to_human(), ); - let wire = Transport::new(service, worker_send, cert, signer, proxy, clock); + let wire = Wire::new(service, worker_send, cert, signer, proxy, clock); let reactor = Reactor::named(wire, popol::Poller::new(), id.to_human())?; let handle = Handle::from(reactor.controller()); let control = thread::spawn({ diff --git a/radicle-node/src/tests/e2e.rs b/radicle-node/src/tests/e2e.rs index 9187a05f..391d27dc 100644 --- a/radicle-node/src/tests/e2e.rs +++ b/radicle-node/src/tests/e2e.rs @@ -20,14 +20,14 @@ use crate::node::NodeId; use crate::service::{routing, FetchLookup, FetchResult}; use crate::storage::git::transport; use crate::test::logger; -use crate::wire::Transport; +use crate::wire::Wire; use crate::{client, client::Runtime, service}; /// Represents a running node. struct Node { id: NodeId, addr: net::SocketAddr, - handle: client::handle::Handle>, + handle: client::handle::Handle>, signer: MemorySigner, storage: Storage, #[allow(dead_code)] diff --git a/radicle-node/src/wire.rs b/radicle-node/src/wire.rs index 7d6b10a3..151f87a6 100644 --- a/radicle-node/src/wire.rs +++ b/radicle-node/src/wire.rs @@ -1,8 +1,8 @@ mod message; -mod transport; +mod protocol; pub use message::{AddressType, MessageType}; -pub use transport::Transport; +pub use protocol::{Wire, WireReader, WireSession, WireWriter}; use std::collections::BTreeMap; use std::convert::TryFrom; @@ -11,8 +11,6 @@ use std::string::FromUtf8Error; use std::{io, mem}; use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt}; -use cyphernet::Sha256; -use netservices::session::{CypherReader, CypherSession, CypherWriter}; use crate::crypto::hash::Digest; use crate::crypto::{PublicKey, Signature, Unverified}; @@ -33,10 +31,6 @@ use crate::storage::refs::SignedRefs; /// Note that in certain cases, we may use a smaller type. pub type Size = u16; -pub type WireSession = CypherSession; -pub type WireReader = CypherReader; -pub type WireWriter = CypherWriter; - #[derive(thiserror::Error, Debug)] pub enum Error { #[error("i/o: {0}")] diff --git a/radicle-node/src/wire/transport.rs b/radicle-node/src/wire/protocol.rs similarity index 97% rename from radicle-node/src/wire/transport.rs rename to radicle-node/src/wire/protocol.rs index cbaaef33..4a79a571 100644 --- a/radicle-node/src/wire/transport.rs +++ b/radicle-node/src/wire/protocol.rs @@ -15,6 +15,7 @@ use cyphernet::{Cert, Digest, EcSign, Sha256}; use nakamoto_net::LocalTime; use netservices::resource::{ListenerEvent, NetAccept, NetTransport, SessionEvent}; use netservices::session::ProtocolArtifact; +use netservices::session::{CypherReader, CypherSession, CypherWriter}; use netservices::{NetConnection, NetSession}; use radicle::collections::HashMap; @@ -25,11 +26,15 @@ use radicle::storage::WriteStorage; use crate::crypto::Signer; use crate::service::reactor::{Fetch, Io}; use crate::service::{routing, session, DisconnectReason, Message, Service}; -use crate::wire::{Decode, Encode, WireSession}; +use crate::wire::{Decode, Encode}; use crate::worker::{WorkerReq, WorkerResp}; use crate::Link; use crate::{address, service}; +pub type WireSession = CypherSession; +pub type WireReader = CypherReader; +pub type WireWriter = CypherWriter; + /// Reactor action. type Action = reactor::Action>, NetTransport>>; @@ -160,8 +165,8 @@ impl Peer { } } -/// Transport protocol implementation for a set of peers. -pub struct Transport { +/// Wire protocol implementation for a set of peers. +pub struct Wire { /// Backing service instance. service: Service, /// Worker pool interface. @@ -180,7 +185,7 @@ pub struct Transport { read_queue: VecDeque, } -impl Transport +impl Wire where R: routing::Store, S: address::Store, @@ -321,7 +326,7 @@ where } } -impl reactor::Handler for Transport +impl reactor::Handler for Wire where R: routing::Store + Send, S: address::Store + Send, @@ -554,7 +559,7 @@ where } } -impl Iterator for Transport +impl Iterator for Wire where R: routing::Store, S: address::Store,