mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-29 05:50:31 +08:00
node: Clean up uses
The re-exports from other crates got quite confusing. Remove all `pub use` from `radicle-node`, and rewrite all `use`s accordingly. The result is a slight increase in the number of `use` lines, but with improved clarity on which type is actually imported.
This commit is contained in:
@@ -5,18 +5,18 @@ use std::io::prelude::*;
|
||||
use std::path::PathBuf;
|
||||
use std::{io, net, time};
|
||||
|
||||
use radicle::storage::refs;
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::net::{UnixListener, UnixStream};
|
||||
#[cfg(windows)]
|
||||
use uds_windows::{UnixListener, UnixStream};
|
||||
|
||||
use radicle::identity::RepoId;
|
||||
use radicle::node::Handle;
|
||||
use radicle::node::NodeId;
|
||||
use radicle::node::{Command, CommandResult};
|
||||
use radicle::storage::refs;
|
||||
use serde_json as json;
|
||||
|
||||
use crate::identity::RepoId;
|
||||
use crate::node::NodeId;
|
||||
use crate::node::{Command, CommandResult};
|
||||
use crate::runtime;
|
||||
use crate::runtime::thread;
|
||||
|
||||
@@ -30,13 +30,13 @@ pub enum Error {
|
||||
#[error("invalid socket path specified: {0}")]
|
||||
InvalidPath(PathBuf),
|
||||
#[error("node: {0}")]
|
||||
Node(#[from] runtime::HandleError),
|
||||
Node(#[from] runtime::handle::Error),
|
||||
}
|
||||
|
||||
/// Listen for commands on the control socket, and process them.
|
||||
pub fn listen<E, H>(listener: UnixListener, handle: H) -> Result<(), Error>
|
||||
where
|
||||
H: Handle<Error = runtime::HandleError> + 'static,
|
||||
H: Handle<Error = runtime::handle::Error> + 'static,
|
||||
H::Sessions: serde::Serialize,
|
||||
CommandResult<E>: From<H::Event>,
|
||||
E: serde::Serialize,
|
||||
@@ -73,14 +73,14 @@ enum CommandError {
|
||||
#[error("(de)serialization failed: {0}")]
|
||||
Serialization(#[from] json::Error),
|
||||
#[error("runtime error: {0}")]
|
||||
Runtime(#[from] runtime::HandleError),
|
||||
Runtime(#[from] runtime::handle::Error),
|
||||
#[error("i/o error: {0}")]
|
||||
Io(#[from] io::Error),
|
||||
}
|
||||
|
||||
fn command<E, H>(stream: &UnixStream, mut handle: H) -> Result<(), CommandError>
|
||||
where
|
||||
H: Handle<Error = runtime::HandleError> + 'static,
|
||||
H: Handle<Error = runtime::handle::Error> + 'static,
|
||||
H::Sessions: serde::Serialize,
|
||||
CommandResult<E>: From<H::Event>,
|
||||
E: serde::Serialize,
|
||||
@@ -257,7 +257,7 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn fetch<W: Write, H: Handle<Error = runtime::HandleError>>(
|
||||
fn fetch<W: Write, H: Handle<Error = runtime::handle::Error>>(
|
||||
id: RepoId,
|
||||
node: NodeId,
|
||||
timeout: time::Duration,
|
||||
@@ -278,14 +278,16 @@ fn fetch<W: Write, H: Handle<Error = runtime::HandleError>>(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::io::prelude::*;
|
||||
use super::*;
|
||||
|
||||
use std::thread;
|
||||
|
||||
use super::*;
|
||||
use crate::identity::RepoId;
|
||||
use crate::node::Handle;
|
||||
use crate::node::policy::Scope;
|
||||
use crate::node::{Alias, Node, NodeId};
|
||||
use radicle::identity::RepoId;
|
||||
use radicle::node::Handle;
|
||||
use radicle::node::policy::Scope;
|
||||
use radicle::node::{Alias, Node, NodeId};
|
||||
use radicle::test::arbitrary;
|
||||
|
||||
use crate::test;
|
||||
|
||||
#[test]
|
||||
@@ -293,7 +295,7 @@ mod tests {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let handle = test::handle::Handle::default();
|
||||
let socket = tmp.path().join("alice.sock");
|
||||
let rids = test::arbitrary::set::<RepoId>(1..3);
|
||||
let rids = arbitrary::set::<RepoId>(1..3);
|
||||
let listener = UnixListener::bind(&socket).unwrap();
|
||||
let nid = handle.nid().unwrap();
|
||||
|
||||
@@ -342,8 +344,8 @@ mod tests {
|
||||
fn test_seed_unseed() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let socket = tmp.path().join("node.sock");
|
||||
let proj = test::arbitrary::r#gen::<RepoId>(1);
|
||||
let peer = test::arbitrary::r#gen::<NodeId>(1);
|
||||
let proj = arbitrary::r#gen::<RepoId>(1);
|
||||
let peer = arbitrary::r#gen::<NodeId>(1);
|
||||
let listener = UnixListener::bind(&socket).unwrap();
|
||||
let mut handle = Node::new(&socket);
|
||||
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
#![allow(clippy::byte_char_slices)]
|
||||
|
||||
pub mod fingerprint;
|
||||
pub mod reactor;
|
||||
pub(crate) mod reactor;
|
||||
pub mod runtime;
|
||||
|
||||
mod control;
|
||||
pub(crate) use radicle_protocol::service;
|
||||
mod wire;
|
||||
mod worker;
|
||||
|
||||
@@ -17,16 +16,12 @@ pub mod test;
|
||||
#[cfg(test)]
|
||||
pub mod tests;
|
||||
|
||||
extern crate radicle_fetch as fetch;
|
||||
extern crate radicle_localtime as localtime;
|
||||
extern crate radicle_protocol as protocol;
|
||||
|
||||
use radicle::version::Version;
|
||||
|
||||
pub use localtime::{LocalDuration, LocalTime};
|
||||
pub use radicle::node::Link;
|
||||
pub use radicle::prelude::Timestamp;
|
||||
pub use radicle::{collections, crypto, git, identity, node, profile, rad, storage};
|
||||
pub use runtime::Runtime;
|
||||
|
||||
/// Node version.
|
||||
pub const VERSION: Version = Version {
|
||||
name: env!("CARGO_PKG_NAME"),
|
||||
@@ -34,14 +29,3 @@ pub const VERSION: Version = Version {
|
||||
version: env!("RADICLE_VERSION"),
|
||||
timestamp: env!("SOURCE_DATE_EPOCH"),
|
||||
};
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::crypto::{PublicKey, Signature};
|
||||
pub use crate::identity::{Did, RepoId};
|
||||
pub use crate::node::{Address, Event, NodeId, config::Network};
|
||||
pub use crate::service::filter::Filter;
|
||||
pub use crate::service::{DisconnectReason, Message};
|
||||
pub use crate::storage::WriteStorage;
|
||||
pub use crate::storage::refs::Refs;
|
||||
pub use crate::{LocalDuration, LocalTime, Timestamp};
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@ use std::str::FromStr;
|
||||
use thiserror::Error;
|
||||
|
||||
use radicle::crypto::Signer as _;
|
||||
use radicle::crypto::ssh::keystore::Keystore;
|
||||
use radicle::node::NodeId;
|
||||
use radicle::profile;
|
||||
|
||||
use radicle_node::crypto::ssh::keystore::Keystore;
|
||||
use radicle_node::fingerprint::{Fingerprint, FingerprintVerification};
|
||||
use radicle_node::{Runtime, VERSION};
|
||||
use radicle_node::{VERSION, runtime::Runtime};
|
||||
use radicle_signals as signals;
|
||||
|
||||
const HELP_MSG: &str = r#"
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::wire;
|
||||
|
||||
pub(crate) use self::controller::{ControlMessage, Controller};
|
||||
pub(crate) use listener::Listener;
|
||||
pub use session::{NoiseSession, ProtocolArtifact, Socks5Session};
|
||||
pub(crate) use session::{NoiseSession, ProtocolArtifact, Socks5Session};
|
||||
pub(crate) use token::{Token, Tokens};
|
||||
pub(crate) use transport::{SessionEvent, Transport};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
pub use mio::Token;
|
||||
pub(crate) use mio::Token;
|
||||
|
||||
pub const WAKER: Token = Token(0);
|
||||
|
||||
|
||||
@@ -12,33 +12,31 @@ use std::os::unix::net::UnixListener;
|
||||
#[cfg(windows)]
|
||||
use uds_windows::UnixListener;
|
||||
|
||||
use handle::Handle;
|
||||
use localtime::LocalTime;
|
||||
use protocol::service;
|
||||
use protocol::service::gossip;
|
||||
use radicle::cob::migrate;
|
||||
use radicle_signals::Signal;
|
||||
use thiserror::Error;
|
||||
|
||||
use radicle::crypto::{Signer as _, SigningKey};
|
||||
use radicle::node;
|
||||
use radicle::node::Event;
|
||||
use radicle::node::UserAgent;
|
||||
use radicle::node::address;
|
||||
use radicle::node::address::Store as _;
|
||||
use radicle::node::events::Emitter;
|
||||
use radicle::node::notifications;
|
||||
use radicle::node::policy::config as policy;
|
||||
use radicle::node::{NodeId, routing};
|
||||
use radicle::profile::Home;
|
||||
use radicle::{Storage, cob, git, storage};
|
||||
use radicle_signals::Signal;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::control;
|
||||
use crate::node::{NodeId, routing};
|
||||
use crate::reactor;
|
||||
use crate::reactor::Reactor;
|
||||
use crate::service::gossip;
|
||||
use crate::wire::Wire;
|
||||
use crate::worker;
|
||||
use crate::{LocalTime, service};
|
||||
|
||||
pub use handle::Error as HandleError;
|
||||
pub use handle::Handle;
|
||||
pub use node::events::Emitter;
|
||||
|
||||
/// Maximum pending worker tasks allowed.
|
||||
pub const MAX_PENDING_TASKS: usize = 1024;
|
||||
|
||||
@@ -11,25 +11,25 @@ use std::os::unix::net::UnixStream;
|
||||
#[cfg(windows)]
|
||||
use uds_windows::UnixStream;
|
||||
|
||||
use protocol::service;
|
||||
use protocol::service::QueryState;
|
||||
use protocol::wire::StreamId;
|
||||
use radicle::crypto::PublicKey;
|
||||
use radicle::identity::RepoId;
|
||||
use radicle::node::events::{Event, Events};
|
||||
use radicle::node::policy;
|
||||
use radicle::node::{Alias, Command, FetchResult};
|
||||
use radicle::node::{Config, NodeId};
|
||||
use radicle::node::{ConnectOptions, ConnectResult, Seeds};
|
||||
use radicle::profile::Home;
|
||||
use radicle::storage::refs;
|
||||
use radicle::storage::refs::RefsAt;
|
||||
use serde_json::json;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::identity::RepoId;
|
||||
use crate::node::{Alias, Command, FetchResult};
|
||||
use crate::profile::Home;
|
||||
use crate::reactor;
|
||||
use crate::runtime::Emitter;
|
||||
use crate::service;
|
||||
use crate::service::QueryState;
|
||||
use crate::storage::refs::RefsAt;
|
||||
use crate::wire;
|
||||
use crate::wire::StreamId;
|
||||
use crate::worker::TaskResult;
|
||||
|
||||
/// An error resulting from a handle method.
|
||||
@@ -409,8 +409,8 @@ impl radicle::node::Handle for Handle {
|
||||
mod debug {
|
||||
//! Serialization formats for the output of [`Handle::debug`] output.
|
||||
|
||||
use radicle_protocol::fetcher;
|
||||
use radicle_protocol::fetcher::FetcherState;
|
||||
use protocol::fetcher;
|
||||
use protocol::fetcher::FetcherState;
|
||||
use serde::Serialize;
|
||||
|
||||
use super::{NodeId, RefsAt, RepoId};
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
use std::thread;
|
||||
|
||||
pub use thread::*;
|
||||
|
||||
use radicle::prelude::NodeId;
|
||||
use radicle::node::NodeId;
|
||||
|
||||
/// Spawn an OS thread.
|
||||
pub fn spawn<D, F, T>(nid: &NodeId, label: D, f: F) -> thread::JoinHandle<T>
|
||||
|
||||
@@ -4,6 +4,4 @@ pub mod node;
|
||||
pub mod peer;
|
||||
pub mod simulator;
|
||||
|
||||
pub use radicle::assert_matches;
|
||||
pub use radicle::test::*;
|
||||
pub use radicle_log::test as logger;
|
||||
use radicle::test::*;
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
use localtime::{LocalDuration, LocalTime};
|
||||
use protocol::service::message::{InventoryAnnouncement, Message, NodeAnnouncement};
|
||||
use radicle::crypto::SigningKey;
|
||||
use radicle::node;
|
||||
use radicle::node::PROTOCOL_VERSION;
|
||||
use radicle::node::UserAgent;
|
||||
use radicle::test::arbitrary;
|
||||
use radicle::test::fixtures::r#gen;
|
||||
|
||||
use crate::test::arbitrary;
|
||||
use crate::{
|
||||
prelude::{LocalDuration, LocalTime, Message},
|
||||
service::message::{InventoryAnnouncement, NodeAnnouncement},
|
||||
};
|
||||
|
||||
pub fn messages(count: usize, now: LocalTime, delta: LocalDuration) -> Vec<Message> {
|
||||
let mut rng = fastrand::Rng::new();
|
||||
|
||||
@@ -5,13 +5,11 @@ use std::time;
|
||||
|
||||
use radicle::crypto::PublicKey;
|
||||
use radicle::git::Oid;
|
||||
use radicle::storage::refs::{self, RefsAt};
|
||||
|
||||
use crate::identity::RepoId;
|
||||
use crate::node::{Alias, Config, ConnectOptions, ConnectResult, Event, FetchResult, Seeds};
|
||||
use crate::runtime::HandleError;
|
||||
use radicle::identity::RepoId;
|
||||
use radicle::node::NodeId;
|
||||
use radicle::node::policy;
|
||||
use radicle::node::{Alias, Config, ConnectOptions, ConnectResult, Event, FetchResult, Seeds};
|
||||
use radicle::storage::refs::{self, RefsAt};
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
pub struct Handle {
|
||||
@@ -22,7 +20,7 @@ pub struct Handle {
|
||||
}
|
||||
|
||||
impl radicle::node::Handle for Handle {
|
||||
type Error = HandleError;
|
||||
type Error = crate::runtime::handle::Error;
|
||||
type Sessions = Vec<radicle::node::Session>;
|
||||
type Events = Vec<Self::Event>;
|
||||
type Event = Result<Event, Self::Error>;
|
||||
|
||||
@@ -9,9 +9,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use crate::node::NodeId;
|
||||
use crate::storage::git::transport;
|
||||
use crate::{Runtime, runtime, runtime::Handle, service};
|
||||
use protocol::service;
|
||||
use radicle::Storage;
|
||||
use radicle::cob;
|
||||
use radicle::cob::issue;
|
||||
@@ -21,6 +19,7 @@ use radicle::git::fmt::refname;
|
||||
use radicle::identity::{RepoId, Visibility};
|
||||
use radicle::node::Config;
|
||||
use radicle::node::Event;
|
||||
use radicle::node::NodeId;
|
||||
use radicle::node::config::ConnectAddress;
|
||||
use radicle::node::policy::store as policy;
|
||||
use radicle::node::seed::Store as _;
|
||||
@@ -29,9 +28,12 @@ use radicle::node::{ConnectOptions, Handle as _};
|
||||
use radicle::node::{Database, POLICIES_DB_FILE};
|
||||
use radicle::profile::{Home, Profile, env};
|
||||
use radicle::rad;
|
||||
use radicle::storage::git::transport;
|
||||
use radicle::storage::{ReadStorage as _, RemoteRepository as _, SignRepository as _};
|
||||
use radicle::test::fixtures;
|
||||
|
||||
use crate::runtime::{self, Runtime, handle::Handle};
|
||||
|
||||
/// A node that can be run.
|
||||
pub struct Node {
|
||||
pub id: NodeId,
|
||||
|
||||
@@ -4,41 +4,40 @@ use std::net;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::str::FromStr;
|
||||
|
||||
use localtime::{LocalDuration, LocalTime};
|
||||
use log::*;
|
||||
|
||||
use protocol::bounded::BoundedVec;
|
||||
use protocol::service;
|
||||
use protocol::service::io::Io;
|
||||
use protocol::service::message::*;
|
||||
use protocol::service::*;
|
||||
use protocol::wire::MessageType;
|
||||
use radicle::Storage;
|
||||
use radicle::crypto::{Signer as _, SigningKey};
|
||||
use radicle::git::Oid;
|
||||
use radicle::identity::RepoId;
|
||||
use radicle::identity::Visibility;
|
||||
use radicle::node;
|
||||
use radicle::node::Database;
|
||||
use radicle::node::Link;
|
||||
use radicle::node::PROTOCOL_VERSION;
|
||||
use radicle::node::UserAgent;
|
||||
use radicle::node::address::Store as _;
|
||||
use radicle::node::{Alias, ConnectOptions, address};
|
||||
use radicle::rad;
|
||||
use radicle::storage::refs;
|
||||
use radicle::storage::refs::{RefsAt, SignedRefs};
|
||||
use radicle::storage::{ReadRepository, RemoteRepository};
|
||||
|
||||
use crate::identity::RepoId;
|
||||
use crate::node;
|
||||
use crate::node::routing::Store as _;
|
||||
use crate::prelude::*;
|
||||
use crate::runtime::Emitter;
|
||||
use crate::service;
|
||||
use crate::service::io::Io;
|
||||
use crate::service::message::*;
|
||||
use crate::service::*;
|
||||
use crate::storage::git::transport::remote;
|
||||
use crate::storage::{RemoteId, WriteStorage};
|
||||
use crate::test::storage::MockStorage;
|
||||
use crate::test::{arbitrary, fixtures};
|
||||
use crate::wire::MessageType;
|
||||
use crate::{Link, LocalDuration, LocalTime};
|
||||
use radicle::node::PROTOCOL_VERSION;
|
||||
use radicle::node::events::Emitter;
|
||||
use radicle::node::events::Events;
|
||||
use radicle::node::policy::config as policy;
|
||||
use radicle::node::policy::{Scope, SeedingPolicy};
|
||||
use radicle_protocol::bounded::BoundedVec;
|
||||
use radicle::node::routing::Store as _;
|
||||
use radicle::node::{Address, Event, NodeId, Timestamp};
|
||||
use radicle::node::{Alias, ConnectOptions, address};
|
||||
use radicle::rad;
|
||||
use radicle::storage::git::transport::remote;
|
||||
use radicle::storage::refs;
|
||||
use radicle::storage::refs::{RefsAt, SignedRefs};
|
||||
use radicle::storage::{ReadRepository, RemoteRepository};
|
||||
use radicle::storage::{RemoteId, WriteStorage};
|
||||
use radicle::test::storage::MockStorage;
|
||||
use radicle::test::{arbitrary, fixtures};
|
||||
|
||||
/// Service instantiation used for testing.
|
||||
pub type Service<S> = service::Service<Database, S>;
|
||||
|
||||
@@ -10,19 +10,20 @@ use std::{fmt, io, net};
|
||||
|
||||
use localtime::{LocalDuration, LocalTime};
|
||||
use log::*;
|
||||
use protocol::service::ServiceState as _;
|
||||
use protocol::service::io::Io;
|
||||
use protocol::service::{DisconnectReason, Message, Metrics};
|
||||
use protocol::worker::FetchError;
|
||||
use protocol::worker::fetch::FetchResult;
|
||||
use radicle::identity::RepoId;
|
||||
use radicle::node::Address;
|
||||
use radicle::node::Link;
|
||||
use radicle::node::NodeId;
|
||||
use radicle::node::events::Event;
|
||||
use radicle_protocol::service::ServiceState as _;
|
||||
use radicle_protocol::worker::FetchError;
|
||||
use radicle::storage::Namespaces;
|
||||
use radicle::storage::{ReadRepository, WriteStorage};
|
||||
|
||||
use crate::Link;
|
||||
use crate::prelude::{Address, RepoId};
|
||||
use crate::service::io::Io;
|
||||
use crate::service::{DisconnectReason, Message, Metrics};
|
||||
use crate::storage::Namespaces;
|
||||
use crate::storage::{ReadRepository, WriteStorage};
|
||||
use crate::test::arbitrary;
|
||||
use crate::worker::fetch;
|
||||
|
||||
use super::peer::Peer;
|
||||
|
||||
@@ -55,7 +56,7 @@ pub enum Input {
|
||||
/// Received messages from a remote peer.
|
||||
Received(NodeId, Vec<Message>),
|
||||
/// Fetch completed for a node.
|
||||
Fetched(RepoId, NodeId, Rc<Result<fetch::FetchResult, FetchError>>),
|
||||
Fetched(RepoId, NodeId, Rc<Result<FetchResult, FetchError>>),
|
||||
/// Used to advance the state machine after some wall time has passed.
|
||||
Wake,
|
||||
}
|
||||
@@ -396,7 +397,7 @@ where
|
||||
};
|
||||
|
||||
match &mut result {
|
||||
Ok(fetch::FetchResult {
|
||||
Ok(FetchResult {
|
||||
namespaces,
|
||||
updated,
|
||||
doc,
|
||||
@@ -632,9 +633,10 @@ where
|
||||
input: Input::Fetched(
|
||||
rid,
|
||||
remote,
|
||||
Rc::new(Ok(fetch::FetchResult {
|
||||
Rc::new(Ok(FetchResult {
|
||||
updated: vec![],
|
||||
canonical: fetch::UpdatedCanonicalRefs::default(),
|
||||
canonical:
|
||||
protocol::worker::fetch::UpdatedCanonicalRefs::default(),
|
||||
namespaces: HashSet::new(),
|
||||
clone: true,
|
||||
doc: arbitrary::r#gen(1),
|
||||
|
||||
@@ -11,52 +11,54 @@ use std::time;
|
||||
use radicle::storage::ReadRepository;
|
||||
use test_log::test;
|
||||
|
||||
use localtime::LocalDuration;
|
||||
use localtime::LocalTime;
|
||||
use protocol::bounded::BoundedVec;
|
||||
use protocol::service;
|
||||
use protocol::service::ServiceState as _;
|
||||
use protocol::service::filter::Filter;
|
||||
use protocol::service::io::Io;
|
||||
use protocol::service::message::*;
|
||||
use protocol::service::*;
|
||||
use protocol::wire::Decode;
|
||||
use protocol::wire::Encode;
|
||||
use protocol::worker::fetch::FetchResult;
|
||||
use radicle::assert_matches;
|
||||
use radicle::cob;
|
||||
use radicle::collections::{RandomMap, RandomSet};
|
||||
use radicle::crypto::SigningKey;
|
||||
use radicle::identity::RepoId;
|
||||
use radicle::identity::Visibility;
|
||||
use radicle::node;
|
||||
use radicle::node::Event;
|
||||
use radicle::node::Link;
|
||||
use radicle::node::Timestamp;
|
||||
use radicle::node::address::Store as _;
|
||||
use radicle::node::config::*;
|
||||
use radicle::node::policy;
|
||||
use radicle::node::refs::Store as _;
|
||||
use radicle::node::routing::Store as _;
|
||||
use radicle::node::{ConnectOptions, DEFAULT_TIMEOUT};
|
||||
use radicle::storage::ReadStorage;
|
||||
use radicle::storage::RefUpdate;
|
||||
use radicle::storage::git::Storage;
|
||||
use radicle::storage::git::transport::{local, remote};
|
||||
use radicle::storage::refs::RefsAt;
|
||||
use radicle::storage::refs::SIGREFS_BRANCH;
|
||||
use radicle::test::arbitrary;
|
||||
use radicle::test::arbitrary::r#gen;
|
||||
use radicle::test::fixtures;
|
||||
use radicle::test::storage::MockRepository;
|
||||
use radicle_protocol::bounded::BoundedVec;
|
||||
|
||||
use crate::collections::{RandomMap, RandomSet};
|
||||
use crate::identity::RepoId;
|
||||
use crate::node;
|
||||
use crate::node::config::*;
|
||||
use crate::prelude::*;
|
||||
use crate::prelude::{LocalDuration, Timestamp};
|
||||
use crate::service::ServiceState as _;
|
||||
use crate::service::filter::Filter;
|
||||
use crate::service::io::Io;
|
||||
use crate::service::message::*;
|
||||
use crate::service::*;
|
||||
use crate::storage::ReadStorage;
|
||||
use crate::storage::git::Storage;
|
||||
use crate::storage::git::transport::{local, remote};
|
||||
use crate::storage::refs::SIGREFS_BRANCH;
|
||||
use crate::test::arbitrary;
|
||||
use crate::test::assert_matches;
|
||||
use crate::test::fixtures;
|
||||
use radicle::test::storage::MockStorage;
|
||||
use radicle::{git, identity, rad};
|
||||
#[allow(unused)]
|
||||
use crate::test::logger;
|
||||
use radicle_log::test as logger;
|
||||
|
||||
use crate::test::peer::Peer;
|
||||
use crate::test::peer::{AMY, BOB, CID};
|
||||
use crate::test::simulator;
|
||||
use crate::test::simulator::Simulation;
|
||||
|
||||
use crate::LocalTime;
|
||||
use crate::test::storage::MockStorage;
|
||||
use crate::wire::Decode;
|
||||
use crate::wire::Encode;
|
||||
use crate::worker::fetch;
|
||||
use crate::{git, identity, rad, runtime, service, test};
|
||||
use crate::{runtime, test};
|
||||
|
||||
/// Default number of tests to run when testing things with high variance.
|
||||
pub const DEFAULT_TEST_CASES: usize = 10;
|
||||
@@ -354,7 +356,7 @@ fn inventory_pruning() {
|
||||
assert_eq!(bob.local_time(), amy.local_time());
|
||||
|
||||
let projects: [RepoId; PROJECTS_TOTAL] =
|
||||
test::arbitrary::set::<RepoId>(PROJECTS_TOTAL..=PROJECTS_TOTAL)
|
||||
arbitrary::set::<RepoId>(PROJECTS_TOTAL..=PROJECTS_TOTAL)
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>()
|
||||
.try_into()
|
||||
@@ -395,13 +397,13 @@ fn inventory_pruning() {
|
||||
#[test]
|
||||
fn seeding() {
|
||||
let mut amy = Peer::amy();
|
||||
let proj_id: identity::RepoId = test::arbitrary::r#gen(1);
|
||||
let proj_id: identity::RepoId = arbitrary::r#gen(1);
|
||||
|
||||
let (cmd, receiver) = Command::seed(proj_id, policy::Scope::default());
|
||||
amy.command(cmd);
|
||||
let policy_change = receiver
|
||||
.recv()
|
||||
.map_err(runtime::HandleError::from)
|
||||
.map_err(runtime::handle::Error::from)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert!(policy_change);
|
||||
@@ -411,7 +413,7 @@ fn seeding() {
|
||||
amy.command(cmd);
|
||||
let policy_change = receiver
|
||||
.recv()
|
||||
.map_err(runtime::HandleError::from)
|
||||
.map_err(runtime::handle::Error::from)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert!(policy_change);
|
||||
@@ -879,7 +881,7 @@ fn refs_announcement_followed() {
|
||||
amy.command(cmd);
|
||||
let policy_change = receiver
|
||||
.recv()
|
||||
.map_err(runtime::HandleError::from)
|
||||
.map_err(runtime::handle::Error::from)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert!(policy_change);
|
||||
@@ -1404,7 +1406,7 @@ fn fetch_missing_inventory_on_schedule() {
|
||||
amy.fetched(
|
||||
rid,
|
||||
*bob.nid(),
|
||||
Err(radicle_protocol::worker::FetchError::Io(
|
||||
Err(protocol::worker::FetchError::Io(
|
||||
io::ErrorKind::ConnectionReset.into(),
|
||||
)),
|
||||
);
|
||||
@@ -1449,7 +1451,7 @@ fn queued_fetch_max_capacity() {
|
||||
amy.elapse(KEEP_ALIVE_DELTA);
|
||||
|
||||
// Finish the 1st fetch.
|
||||
amy.fetched(rid1, *bob.nid(), Ok(fetch::FetchResult::new(doc.clone())));
|
||||
amy.fetched(rid1, *bob.nid(), Ok(FetchResult::new(doc.clone())));
|
||||
|
||||
// Now the 1st fetch is done, the 2nd fetch is dequeued.
|
||||
assert_eq!(amy.fetches().next(), Some((rid2, *bob.nid())));
|
||||
@@ -1457,7 +1459,7 @@ fn queued_fetch_max_capacity() {
|
||||
assert_matches!(amy.fetches().next(), None);
|
||||
|
||||
// Finish the 2nd fetch.
|
||||
amy.fetched(rid2, *bob.nid(), Ok(fetch::FetchResult::new(doc)));
|
||||
amy.fetched(rid2, *bob.nid(), Ok(FetchResult::new(doc)));
|
||||
// Now the 2nd fetch is done, the 3rd fetch is dequeued.
|
||||
assert_eq!(amy.fetches().next(), Some((rid3, *bob.nid())));
|
||||
}
|
||||
@@ -1513,7 +1515,7 @@ fn orphaned_fetch_blocks_repo_from_all_nodes() {
|
||||
|
||||
// Delivering the missing result (what the fix guarantees) clears the entry
|
||||
// and the queued fetch from the other node proceeds.
|
||||
amy.fetched(rid, *bob.nid(), Ok(fetch::FetchResult::new(doc)));
|
||||
amy.fetched(rid, *bob.nid(), Ok(FetchResult::new(doc)));
|
||||
assert_eq!(amy.fetches().next(), Some((rid, *cid.nid())));
|
||||
}
|
||||
|
||||
@@ -1577,12 +1579,12 @@ fn queued_fetch_from_ann_same_rid() {
|
||||
amy.fetched(
|
||||
rid,
|
||||
*bob.nid(),
|
||||
Ok(fetch::FetchResult {
|
||||
Ok(FetchResult {
|
||||
updated: vec![RefUpdate::Created {
|
||||
name: refname.clone(),
|
||||
oid,
|
||||
}],
|
||||
canonical: fetch::UpdatedCanonicalRefs::default(),
|
||||
canonical: protocol::worker::fetch::UpdatedCanonicalRefs::default(),
|
||||
namespaces: [*cid.nid()].into_iter().collect(),
|
||||
clone: false,
|
||||
doc: arbitrary::r#gen(1),
|
||||
@@ -1636,7 +1638,7 @@ fn queued_fetch_from_command_same_rid() {
|
||||
amy.elapse(KEEP_ALIVE_DELTA);
|
||||
|
||||
// Finish the 1st fetch.
|
||||
amy.fetched(rid1, nid, Ok(arbitrary::r#gen::<fetch::FetchResult>(1)));
|
||||
amy.fetched(rid1, nid, Ok(arbitrary::r#gen::<FetchResult>(1)));
|
||||
// Now the 1st fetch is done, the 2nd fetch is dequeued.
|
||||
let (rid, nid) = amy.fetches().next().unwrap();
|
||||
assert_eq!(rid, rid1);
|
||||
@@ -1646,7 +1648,7 @@ fn queued_fetch_from_command_same_rid() {
|
||||
assert_matches!(amy.fetches().next(), None);
|
||||
|
||||
// Finish the 2nd fetch.
|
||||
amy.fetched(rid1, nid, Ok(arbitrary::r#gen::<fetch::FetchResult>(1)));
|
||||
amy.fetched(rid1, nid, Ok(arbitrary::r#gen::<FetchResult>(1)));
|
||||
// Now the 2nd fetch is done, the 3rd fetch is dequeued.
|
||||
assert_matches!(amy.fetches().next(), Some((rid, nid)) if rid == rid1 && peers.remove(&nid));
|
||||
// All fetches were initiated.
|
||||
|
||||
@@ -19,11 +19,11 @@ use radicle::test::fixtures;
|
||||
use radicle::{assert_matches, rad};
|
||||
use radicle::{git, issue};
|
||||
|
||||
use crate::node::config::Limits;
|
||||
use crate::node::{Config, ConnectOptions};
|
||||
use crate::service;
|
||||
use crate::storage::git::transport;
|
||||
use crate::test::node::{Node, NodeHandle, converge};
|
||||
use protocol::service;
|
||||
use radicle::node::config::Limits;
|
||||
use radicle::node::{Config, ConnectOptions};
|
||||
use radicle::storage::git::transport;
|
||||
|
||||
mod config {
|
||||
use super::*;
|
||||
|
||||
@@ -15,7 +15,14 @@ use cyphernet::proxy::socks5;
|
||||
use cyphernet::{Digest, Sha256};
|
||||
use localtime::{LocalDuration, LocalTime};
|
||||
use mio::net::TcpStream;
|
||||
|
||||
use protocol::deserializer::Deserializer;
|
||||
use protocol::service;
|
||||
use protocol::service::io::Io;
|
||||
use protocol::service::{DisconnectReason, Metrics, Service, session};
|
||||
use protocol::wire::frame;
|
||||
use protocol::wire::frame::{Frame, FrameData, StreamId};
|
||||
use protocol::wire::*;
|
||||
use protocol::worker::{FetchRequest, FetchResult};
|
||||
use radicle::collections::{RandomMap, RandomSet};
|
||||
use radicle::crypto::{self, Signer as _};
|
||||
use radicle::node::Link;
|
||||
@@ -23,21 +30,13 @@ use radicle::node::NodeId;
|
||||
#[cfg(any(feature = "i2p", feature = "tor"))]
|
||||
use radicle::node::config::AddressConfig;
|
||||
use radicle::storage::WriteStorage;
|
||||
use radicle_protocol::deserializer::Deserializer;
|
||||
pub use radicle_protocol::wire::frame;
|
||||
pub use radicle_protocol::wire::frame::{Frame, FrameData, StreamId};
|
||||
pub use radicle_protocol::wire::*;
|
||||
use radicle_protocol::worker::{FetchRequest, FetchResult};
|
||||
|
||||
use crate::reactor;
|
||||
use crate::reactor::{Listener, Transport};
|
||||
use crate::reactor::{NoiseSession, ProtocolArtifact, SessionEvent, Socks5Session};
|
||||
use crate::reactor::{Token, Tokens};
|
||||
use crate::service;
|
||||
use crate::service::io::Io;
|
||||
use crate::service::{DisconnectReason, Metrics, Service, session};
|
||||
use crate::worker;
|
||||
use crate::worker::{ChannelEvent, ChannelsConfig};
|
||||
use crate::worker::channels::{ChannelEvent, ChannelsConfig};
|
||||
use crate::worker::{Task, TaskResult};
|
||||
|
||||
/// NoiseXK handshake pattern.
|
||||
@@ -73,7 +72,7 @@ type Action = reactor::Action<Listener, Transport<WireSession>>;
|
||||
/// A worker stream.
|
||||
struct Stream {
|
||||
/// Channels.
|
||||
channels: worker::Channels,
|
||||
channels: worker::channels::Channels,
|
||||
/// Data sent.
|
||||
sent_bytes: usize,
|
||||
/// Data received.
|
||||
@@ -81,7 +80,7 @@ struct Stream {
|
||||
}
|
||||
|
||||
impl Stream {
|
||||
fn new(channels: worker::Channels) -> Self {
|
||||
fn new(channels: worker::channels::Channels) -> Self {
|
||||
Self {
|
||||
channels,
|
||||
sent_bytes: 0,
|
||||
@@ -123,7 +122,7 @@ impl Streams {
|
||||
}
|
||||
|
||||
/// Open a new stream.
|
||||
fn open(&mut self, config: ChannelsConfig) -> (StreamId, worker::Channels) {
|
||||
fn open(&mut self, config: ChannelsConfig) -> (StreamId, worker::channels::Channels) {
|
||||
self.seq += 1;
|
||||
|
||||
let id = StreamId::git(self.link)
|
||||
@@ -137,8 +136,12 @@ impl Streams {
|
||||
}
|
||||
|
||||
/// Register an open stream.
|
||||
fn register(&mut self, stream: StreamId, config: ChannelsConfig) -> Option<worker::Channels> {
|
||||
let (wire, worker) = worker::Channels::pair(config)
|
||||
fn register(
|
||||
&mut self,
|
||||
stream: StreamId,
|
||||
config: ChannelsConfig,
|
||||
) -> Option<worker::channels::Channels> {
|
||||
let (wire, worker) = worker::channels::Channels::pair(config)
|
||||
.expect("Streams::register: fatal: unable to create channels");
|
||||
|
||||
match self.streams.entry(stream) {
|
||||
@@ -1029,7 +1032,7 @@ where
|
||||
self.service.fetched(
|
||||
rid,
|
||||
remote,
|
||||
Err(crate::worker::FetchError::Io(io::Error::new(
|
||||
Err(protocol::worker::FetchError::Io(io::Error::new(
|
||||
io::ErrorKind::NotConnected,
|
||||
"peer disconnected before fetch could start",
|
||||
))),
|
||||
@@ -1288,18 +1291,19 @@ mod logger {
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
use radicle_protocol::service::ServiceState as _;
|
||||
use protocol::service::ServiceState as _;
|
||||
use protocol::service::{Message, ZeroBytes};
|
||||
use radicle::identity::RepoId;
|
||||
use radicle::node;
|
||||
use radicle::test::arbitrary;
|
||||
use radicle::test::storage::MockStorage;
|
||||
|
||||
use crate::identity::RepoId;
|
||||
use crate::node;
|
||||
use crate::service::{Message, ZeroBytes};
|
||||
use crate::test::storage::MockStorage;
|
||||
use crate::wire;
|
||||
use crate::wire::varint;
|
||||
|
||||
#[test]
|
||||
fn test_pong_message_with_extension() {
|
||||
use radicle_protocol::deserializer;
|
||||
use protocol::deserializer;
|
||||
|
||||
let mut stream = Vec::new();
|
||||
let pong = Message::Pong {
|
||||
@@ -1330,7 +1334,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_inventory_ann_with_extension() {
|
||||
use radicle_protocol::deserializer;
|
||||
use protocol::deserializer;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct MessageWithExt {
|
||||
@@ -1354,9 +1358,9 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
let rid = radicle::test::arbitrary::r#gen(1);
|
||||
let pk = radicle::test::arbitrary::r#gen(1);
|
||||
let sig: [u8; 64] = radicle::test::arbitrary::r#gen(1);
|
||||
let rid = arbitrary::r#gen(1);
|
||||
let pk = arbitrary::r#gen(1);
|
||||
let sig: [u8; 64] = arbitrary::r#gen(1);
|
||||
|
||||
// Message with extension.
|
||||
let mut stream = Vec::new();
|
||||
@@ -1427,14 +1431,14 @@ mod test {
|
||||
// Returns the wire, the repo id, and bob's id/address.
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn wire_with_active_fetch() -> (
|
||||
Wire<crate::node::Database, MockStorage>,
|
||||
Wire<radicle::node::Database, MockStorage>,
|
||||
RepoId,
|
||||
NodeId,
|
||||
NetAddr<HostName>,
|
||||
) {
|
||||
use crate::test::peer::Peer as TestPeer;
|
||||
|
||||
let storage = crate::test::arbitrary::nonempty_storage(1);
|
||||
let storage = arbitrary::nonempty_storage(1);
|
||||
let rid = *storage.repos.keys().next().unwrap();
|
||||
let mut alice = TestPeer::with_storage("alice", 7, storage);
|
||||
let bob = TestPeer::bob();
|
||||
@@ -1447,7 +1451,7 @@ mod test {
|
||||
// Start a fetch from Bob so the service holds `active[rid] = { from: bob }`.
|
||||
alice.connect_to(&bob);
|
||||
let (cmd, _recv) =
|
||||
crate::service::Command::fetch(rid, bob_id, radicle::node::DEFAULT_TIMEOUT, None);
|
||||
protocol::service::Command::fetch(rid, bob_id, radicle::node::DEFAULT_TIMEOUT, None);
|
||||
alice.command(cmd);
|
||||
assert!(
|
||||
alice.fetches().any(|(r, _)| r == rid),
|
||||
@@ -1471,7 +1475,7 @@ mod test {
|
||||
stream: StreamId::git(Link::Outbound).nth(1).unwrap(),
|
||||
result: FetchResult::Initiator {
|
||||
rid,
|
||||
result: Err(crate::worker::FetchError::Io(std::io::Error::from(
|
||||
result: Err(protocol::worker::FetchError::Io(std::io::Error::from(
|
||||
std::io::ErrorKind::TimedOut,
|
||||
))),
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
mod channels;
|
||||
pub(crate) mod channels;
|
||||
mod upload_pack;
|
||||
|
||||
pub mod fetch;
|
||||
@@ -7,8 +7,10 @@ pub mod garbage;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use channels::Channels;
|
||||
use crossbeam_channel as chan;
|
||||
|
||||
use protocol::wire::StreamId;
|
||||
use protocol::worker::{AuthorizationError, FetchError, FetchRequest, FetchResult, UploadError};
|
||||
use radicle::identity::RepoId;
|
||||
use radicle::node::notifications;
|
||||
use radicle::node::policy::config as policy;
|
||||
@@ -18,14 +20,7 @@ use radicle::storage::refs::RefsAt;
|
||||
use radicle::storage::{ReadRepository, ReadStorage};
|
||||
use radicle::{Storage, cob, crypto};
|
||||
|
||||
pub use radicle_protocol::worker::{
|
||||
AuthorizationError, FetchError, FetchRequest, FetchResult, UploadError,
|
||||
};
|
||||
|
||||
use crate::runtime::{Handle, thread};
|
||||
use crate::wire::StreamId;
|
||||
|
||||
pub use channels::{ChannelEvent, Channels, ChannelsConfig};
|
||||
use crate::runtime::{handle::Handle, thread};
|
||||
|
||||
/// Worker pool configuration.
|
||||
pub struct Config {
|
||||
@@ -236,15 +231,15 @@ impl Worker {
|
||||
rid: RepoId,
|
||||
remote: NodeId,
|
||||
refs_at: Option<Vec<RefsAt>>,
|
||||
fetch_config: radicle_fetch::Config,
|
||||
fetch_config: ::fetch::Config,
|
||||
channels: channels::ChannelsFlush,
|
||||
notifs: notifications::StoreWriter,
|
||||
) -> Result<fetch::FetchResult, FetchError> {
|
||||
) -> Result<protocol::worker::fetch::FetchResult, FetchError> {
|
||||
let FetchConfig { local, expiry } = &self.fetch_config;
|
||||
// N.b. if the `rid` is blocked this will return an error, so
|
||||
// we won't continue with any further set up of the fetch.
|
||||
let allowed = radicle_fetch::Allowed::from_config(rid, &self.policies)?;
|
||||
let blocked = radicle_fetch::BlockList::from_config(&self.policies)?;
|
||||
let allowed = ::fetch::Allowed::from_config(rid, &self.policies)?;
|
||||
let blocked = ::fetch::BlockList::from_config(&self.policies)?;
|
||||
|
||||
let mut cache = self.cache.clone();
|
||||
let handle = fetch::Handle::new(
|
||||
@@ -278,7 +273,7 @@ impl Worker {
|
||||
|
||||
/// A pool of workers. One thread is allocated for each worker.
|
||||
pub struct Pool {
|
||||
pool: Vec<thread::JoinHandle<Result<(), chan::RecvError>>>,
|
||||
pool: Vec<std::thread::JoinHandle<Result<(), chan::RecvError>>>,
|
||||
}
|
||||
|
||||
impl Pool {
|
||||
@@ -317,7 +312,7 @@ impl Pool {
|
||||
/// Run the worker pool.
|
||||
///
|
||||
/// Blocks until all worker threads have exited.
|
||||
pub fn run(self) -> thread::Result<()> {
|
||||
pub fn run(self) -> std::thread::Result<()> {
|
||||
for (i, worker) in self.pool.into_iter().enumerate() {
|
||||
if let Err(err) = worker.join()? {
|
||||
log::trace!(target: "pool", "Worker {i} exited: {err}");
|
||||
|
||||
@@ -6,8 +6,8 @@ use crossbeam_channel as chan;
|
||||
use radicle::node::NodeId;
|
||||
use radicle::node::config::FetchPackSizeLimit;
|
||||
|
||||
use crate::runtime::Handle;
|
||||
use crate::wire::StreamId;
|
||||
use crate::runtime::handle::Handle;
|
||||
use protocol::wire::StreamId;
|
||||
|
||||
/// Maximum size of channel used to communicate with a worker.
|
||||
/// Note that as long as we're using [`std::io::copy`] to copy data from the
|
||||
@@ -71,7 +71,7 @@ impl ChannelsFlush {
|
||||
}
|
||||
}
|
||||
|
||||
impl radicle_fetch::transport::ConnectionStream for ChannelsFlush {
|
||||
impl fetch::transport::ConnectionStream for ChannelsFlush {
|
||||
type Read = ChannelReader;
|
||||
type Write = ChannelFlushWriter;
|
||||
|
||||
@@ -257,7 +257,7 @@ pub struct ChannelFlushWriter<T = Vec<u8>> {
|
||||
remote: NodeId,
|
||||
}
|
||||
|
||||
impl radicle_fetch::transport::SignalEof for ChannelFlushWriter<Vec<u8>> {
|
||||
impl fetch::transport::SignalEof for ChannelFlushWriter<Vec<u8>> {
|
||||
fn eof(&mut self) -> io::Result<()> {
|
||||
self.writer.send(ChannelEvent::Eof)?;
|
||||
self.flush()
|
||||
|
||||
@@ -1,34 +1,32 @@
|
||||
use radicle::cob::store::access::ReadOnly;
|
||||
use radicle::storage::git::TempRepository;
|
||||
pub(crate) use radicle_protocol::worker::fetch::error;
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
use std::str::FromStr;
|
||||
|
||||
use fetch::git::refs::Applied;
|
||||
use fetch::{Allowed, BlockList};
|
||||
use localtime::LocalTime;
|
||||
|
||||
pub(crate) use protocol::worker::fetch::error;
|
||||
use protocol::worker::fetch::{FetchResult, UpdatedCanonicalRefs};
|
||||
use radicle::cob::TypedId;
|
||||
use radicle::cob::store::access::ReadOnly;
|
||||
use radicle::crypto::PublicKey;
|
||||
use radicle::prelude::NodeId;
|
||||
use radicle::prelude::RepoId;
|
||||
use radicle::storage::git::Repository;
|
||||
use radicle::storage::git::TempRepository;
|
||||
use radicle::storage::refs::RefsAt;
|
||||
use radicle::storage::{
|
||||
ReadRepository, ReadStorage as _, RefUpdate, RemoteRepository, WriteRepository as _,
|
||||
};
|
||||
use radicle::{Storage, cob, git, node};
|
||||
use radicle_fetch::git::refs::Applied;
|
||||
use radicle_fetch::{Allowed, BlockList};
|
||||
pub use radicle_protocol::worker::fetch::{FetchResult, UpdatedCanonicalRefs};
|
||||
|
||||
use super::channels::ChannelsFlush;
|
||||
|
||||
pub enum Handle {
|
||||
Clone {
|
||||
handle: radicle_fetch::Handle<TempRepository, ChannelsFlush>,
|
||||
handle: fetch::Handle<TempRepository, ChannelsFlush>,
|
||||
},
|
||||
Pull {
|
||||
handle: radicle_fetch::Handle<Repository, ChannelsFlush>,
|
||||
handle: fetch::Handle<Repository, ChannelsFlush>,
|
||||
notifications: node::notifications::StoreWriter,
|
||||
},
|
||||
}
|
||||
@@ -46,14 +44,14 @@ impl Handle {
|
||||
let exists = storage.contains(&rid)?;
|
||||
if exists {
|
||||
let repo = storage.repository(rid)?;
|
||||
let handle = radicle_fetch::Handle::new(local, repo, follow, blocked, channels)?;
|
||||
let handle = fetch::Handle::new(local, repo, follow, blocked, channels)?;
|
||||
Ok(Handle::Pull {
|
||||
handle,
|
||||
notifications,
|
||||
})
|
||||
} else {
|
||||
let repo = storage.temporary_repository(rid)?;
|
||||
let handle = radicle_fetch::Handle::new(local, repo, follow, blocked, channels)?;
|
||||
let handle = fetch::Handle::new(local, repo, follow, blocked, channels)?;
|
||||
Ok(Handle::Clone { handle })
|
||||
}
|
||||
}
|
||||
@@ -64,14 +62,14 @@ impl Handle {
|
||||
storage: &Storage,
|
||||
cache: &mut cob::cache::StoreWriter,
|
||||
refsdb: &mut D,
|
||||
config: radicle_fetch::Config,
|
||||
config: fetch::Config,
|
||||
remote: PublicKey,
|
||||
refs_at: Option<Vec<RefsAt>>,
|
||||
) -> Result<FetchResult, error::Fetch> {
|
||||
let (result, clone, notifs) = match self {
|
||||
Self::Clone { mut handle } => {
|
||||
log::debug!(target: "worker", "{} cloning from {remote}", handle.local());
|
||||
match radicle_fetch::clone(&mut handle, config, remote) {
|
||||
match fetch::clone(&mut handle, config, remote) {
|
||||
Err(err) => {
|
||||
handle.into_inner().cleanup();
|
||||
return Err(err.into());
|
||||
@@ -91,7 +89,7 @@ impl Handle {
|
||||
notifications,
|
||||
} => {
|
||||
log::debug!(target: "worker", "{} pulling from {remote}", handle.local());
|
||||
let result = radicle_fetch::pull(&mut handle, config, remote, refs_at)?;
|
||||
let result = fetch::pull(&mut handle, config, remote, refs_at)?;
|
||||
(result, false, Some(notifications))
|
||||
}
|
||||
};
|
||||
@@ -101,7 +99,7 @@ impl Handle {
|
||||
}
|
||||
|
||||
match result {
|
||||
radicle_fetch::FetchResult::Failed {
|
||||
fetch::FetchResult::Failed {
|
||||
threshold,
|
||||
delegates,
|
||||
validations,
|
||||
@@ -114,7 +112,7 @@ impl Handle {
|
||||
delegates: delegates.into_iter().map(|key| key.to_string()).collect(),
|
||||
})
|
||||
}
|
||||
radicle_fetch::FetchResult::Success {
|
||||
fetch::FetchResult::Success {
|
||||
applied,
|
||||
remotes,
|
||||
validations,
|
||||
@@ -164,7 +162,7 @@ impl Handle {
|
||||
// Post notifications for the given refs.
|
||||
fn notify(
|
||||
rid: &RepoId,
|
||||
refs: &radicle_fetch::git::refs::Applied<'static>,
|
||||
refs: &fetch::git::refs::Applied<'static>,
|
||||
store: &mut node::notifications::StoreWriter,
|
||||
) -> Result<(), error::Fetch> {
|
||||
let now = LocalTime::now();
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::io::{Read, Write};
|
||||
use std::process::{Command, ExitStatus, Stdio};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use radicle_fetch::{ByteSlice as _, RemoteProgress};
|
||||
use fetch::{ByteSlice as _, RemoteProgress};
|
||||
|
||||
use radicle::Storage;
|
||||
use radicle::identity::RepoId;
|
||||
@@ -91,7 +91,7 @@ where
|
||||
let mut stdout = io::BufReader::new(child.stdout.take().unwrap());
|
||||
let reporter = std::sync::Mutex::new(Reporter::new(header.repo, remote, emitter.clone(), send));
|
||||
|
||||
thread::scope(|s| {
|
||||
std::thread::scope(|s| {
|
||||
thread::spawn_scoped(nid, "upload-pack", s, || {
|
||||
let mut buffer = [0; u16::MAX as usize + 1];
|
||||
loop {
|
||||
|
||||
Reference in New Issue
Block a user