node: Rename `Transport` to `Wire`

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier 2023-01-16 17:03:50 +01:00
parent 63e7248847
commit 741f7c9651
No known key found for this signature in database
4 changed files with 19 additions and 20 deletions

View File

@ -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<G: crypto::Signer + EcSign<Pk = NodeId, Sig = Signature> + Clone> {
pub id: NodeId,
pub handle: Handle<Transport<routing::Table, address::Book, radicle::Storage, G>>,
pub handle: Handle<Wire<routing::Table, address::Book, radicle::Storage, G>>,
pub control: thread::JoinHandle<Result<(), control::Error>>,
pub reactor: Reactor<Transport<routing::Table, address::Book, radicle::Storage, G>>,
pub reactor: Reactor<Wire<routing::Table, address::Book, radicle::Storage, G>>,
pub pool: WorkerPool,
pub local_addrs: Vec<net::SocketAddr>,
}
@ -117,7 +117,7 @@ impl<G: crypto::Signer + EcSign<Pk = NodeId, Sig = Signature> + 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({

View File

@ -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<Transport<routing::Table, address::Book, Storage, MemorySigner>>,
handle: client::handle::Handle<Wire<routing::Table, address::Book, Storage, MemorySigner>>,
signer: MemorySigner,
storage: Storage,
#[allow(dead_code)]

View File

@ -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<G> = CypherSession<G, Sha256>;
pub type WireReader = CypherReader<Sha256>;
pub type WireWriter<G> = CypherWriter<G, Sha256>;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("i/o: {0}")]

View File

@ -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<G> = CypherSession<G, Sha256>;
pub type WireReader = CypherReader<Sha256>;
pub type WireWriter<G> = CypherWriter<G, Sha256>;
/// Reactor action.
type Action<G> = reactor::Action<NetAccept<WireSession<G>>, NetTransport<WireSession<G>>>;
@ -160,8 +165,8 @@ impl<G: Signer + EcSign> Peer<G> {
}
}
/// Transport protocol implementation for a set of peers.
pub struct Transport<R, S, W, G: Signer + EcSign> {
/// Wire protocol implementation for a set of peers.
pub struct Wire<R, S, W, G: Signer + EcSign> {
/// Backing service instance.
service: Service<R, S, W, G>,
/// Worker pool interface.
@ -180,7 +185,7 @@ pub struct Transport<R, S, W, G: Signer + EcSign> {
read_queue: VecDeque<u8>,
}
impl<R, S, W, G> Transport<R, S, W, G>
impl<R, S, W, G> Wire<R, S, W, G>
where
R: routing::Store,
S: address::Store,
@ -321,7 +326,7 @@ where
}
}
impl<R, S, W, G> reactor::Handler for Transport<R, S, W, G>
impl<R, S, W, G> reactor::Handler for Wire<R, S, W, G>
where
R: routing::Store + Send,
S: address::Store + Send,
@ -554,7 +559,7 @@ where
}
}
impl<R, S, W, G> Iterator for Transport<R, S, W, G>
impl<R, S, W, G> Iterator for Wire<R, S, W, G>
where
R: routing::Store,
S: address::Store,