node: Rename `Transport` to `Wire`
Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
parent
63e7248847
commit
741f7c9651
|
|
@ -12,7 +12,7 @@ use crate::control;
|
||||||
use crate::crypto::Signature;
|
use crate::crypto::Signature;
|
||||||
use crate::node::NodeId;
|
use crate::node::NodeId;
|
||||||
use crate::service::{routing, tracking};
|
use crate::service::{routing, tracking};
|
||||||
use crate::wire::Transport;
|
use crate::wire::Wire;
|
||||||
use crate::worker::{WorkerPool, WorkerReq};
|
use crate::worker::{WorkerPool, WorkerReq};
|
||||||
use crate::{crypto, profile, service, LocalTime};
|
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.
|
/// 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 struct Runtime<G: crypto::Signer + EcSign<Pk = NodeId, Sig = Signature> + Clone> {
|
||||||
pub id: NodeId,
|
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 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 pool: WorkerPool,
|
||||||
pub local_addrs: Vec<net::SocketAddr>,
|
pub local_addrs: Vec<net::SocketAddr>,
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +117,7 @@ impl<G: crypto::Signer + EcSign<Pk = NodeId, Sig = Signature> + Clone + 'static>
|
||||||
worker_recv,
|
worker_recv,
|
||||||
id.to_human(),
|
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 reactor = Reactor::named(wire, popol::Poller::new(), id.to_human())?;
|
||||||
let handle = Handle::from(reactor.controller());
|
let handle = Handle::from(reactor.controller());
|
||||||
let control = thread::spawn({
|
let control = thread::spawn({
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,14 @@ use crate::node::NodeId;
|
||||||
use crate::service::{routing, FetchLookup, FetchResult};
|
use crate::service::{routing, FetchLookup, FetchResult};
|
||||||
use crate::storage::git::transport;
|
use crate::storage::git::transport;
|
||||||
use crate::test::logger;
|
use crate::test::logger;
|
||||||
use crate::wire::Transport;
|
use crate::wire::Wire;
|
||||||
use crate::{client, client::Runtime, service};
|
use crate::{client, client::Runtime, service};
|
||||||
|
|
||||||
/// Represents a running node.
|
/// Represents a running node.
|
||||||
struct Node {
|
struct Node {
|
||||||
id: NodeId,
|
id: NodeId,
|
||||||
addr: net::SocketAddr,
|
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,
|
signer: MemorySigner,
|
||||||
storage: Storage,
|
storage: Storage,
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
mod message;
|
mod message;
|
||||||
mod transport;
|
mod protocol;
|
||||||
|
|
||||||
pub use message::{AddressType, MessageType};
|
pub use message::{AddressType, MessageType};
|
||||||
pub use transport::Transport;
|
pub use protocol::{Wire, WireReader, WireSession, WireWriter};
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
@ -11,8 +11,6 @@ use std::string::FromUtf8Error;
|
||||||
use std::{io, mem};
|
use std::{io, mem};
|
||||||
|
|
||||||
use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use cyphernet::Sha256;
|
|
||||||
use netservices::session::{CypherReader, CypherSession, CypherWriter};
|
|
||||||
|
|
||||||
use crate::crypto::hash::Digest;
|
use crate::crypto::hash::Digest;
|
||||||
use crate::crypto::{PublicKey, Signature, Unverified};
|
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.
|
/// Note that in certain cases, we may use a smaller type.
|
||||||
pub type Size = u16;
|
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)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("i/o: {0}")]
|
#[error("i/o: {0}")]
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ use cyphernet::{Cert, Digest, EcSign, Sha256};
|
||||||
use nakamoto_net::LocalTime;
|
use nakamoto_net::LocalTime;
|
||||||
use netservices::resource::{ListenerEvent, NetAccept, NetTransport, SessionEvent};
|
use netservices::resource::{ListenerEvent, NetAccept, NetTransport, SessionEvent};
|
||||||
use netservices::session::ProtocolArtifact;
|
use netservices::session::ProtocolArtifact;
|
||||||
|
use netservices::session::{CypherReader, CypherSession, CypherWriter};
|
||||||
use netservices::{NetConnection, NetSession};
|
use netservices::{NetConnection, NetSession};
|
||||||
|
|
||||||
use radicle::collections::HashMap;
|
use radicle::collections::HashMap;
|
||||||
|
|
@ -25,11 +26,15 @@ use radicle::storage::WriteStorage;
|
||||||
use crate::crypto::Signer;
|
use crate::crypto::Signer;
|
||||||
use crate::service::reactor::{Fetch, Io};
|
use crate::service::reactor::{Fetch, Io};
|
||||||
use crate::service::{routing, session, DisconnectReason, Message, Service};
|
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::worker::{WorkerReq, WorkerResp};
|
||||||
use crate::Link;
|
use crate::Link;
|
||||||
use crate::{address, service};
|
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.
|
/// Reactor action.
|
||||||
type Action<G> = reactor::Action<NetAccept<WireSession<G>>, NetTransport<WireSession<G>>>;
|
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.
|
/// Wire protocol implementation for a set of peers.
|
||||||
pub struct Transport<R, S, W, G: Signer + EcSign> {
|
pub struct Wire<R, S, W, G: Signer + EcSign> {
|
||||||
/// Backing service instance.
|
/// Backing service instance.
|
||||||
service: Service<R, S, W, G>,
|
service: Service<R, S, W, G>,
|
||||||
/// Worker pool interface.
|
/// Worker pool interface.
|
||||||
|
|
@ -180,7 +185,7 @@ pub struct Transport<R, S, W, G: Signer + EcSign> {
|
||||||
read_queue: VecDeque<u8>,
|
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
|
where
|
||||||
R: routing::Store,
|
R: routing::Store,
|
||||||
S: address::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
|
where
|
||||||
R: routing::Store + Send,
|
R: routing::Store + Send,
|
||||||
S: address::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
|
where
|
||||||
R: routing::Store,
|
R: routing::Store,
|
||||||
S: address::Store,
|
S: address::Store,
|
||||||
Loading…
Reference in New Issue