node: Remove `Handle::inventory` method
This commit is contained in:
parent
caaa7581e6
commit
05d7090326
|
|
@ -79,7 +79,7 @@ fn command<H: Handle<Error = runtime::HandleError>>(
|
|||
handle: &mut H,
|
||||
) -> Result<(), CommandError> {
|
||||
let mut reader = BufReader::new(stream);
|
||||
let mut writer = LineWriter::new(stream);
|
||||
let writer = LineWriter::new(stream);
|
||||
let mut line = String::new();
|
||||
|
||||
reader.read_line(&mut line)?;
|
||||
|
|
@ -187,14 +187,6 @@ fn command<H: Handle<Error = runtime::HandleError>>(
|
|||
CommandName::Status => {
|
||||
CommandResult::ok().to_writer(writer).ok();
|
||||
}
|
||||
CommandName::Inventory => match handle.inventory() {
|
||||
Ok(c) => {
|
||||
for id in c.iter() {
|
||||
writeln!(writer, "{id}")?;
|
||||
}
|
||||
}
|
||||
Err(e) => return Err(CommandError::Runtime(e)),
|
||||
},
|
||||
CommandName::Shutdown => {
|
||||
return Err(CommandError::Shutdown);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,23 +185,6 @@ impl<G: Signer + Ecdh + 'static> radicle::node::Handle for Handle<G> {
|
|||
Ok(sessions)
|
||||
}
|
||||
|
||||
fn inventory(&self) -> Result<chan::Receiver<Id>, Error> {
|
||||
let (sender, receiver) = chan::unbounded();
|
||||
let query: Arc<QueryState> = Arc::new(move |state| {
|
||||
for id in state.inventory()?.iter() {
|
||||
if sender.send(*id).is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
let (err_sender, err_receiver) = chan::bounded(1);
|
||||
self.command(service::Command::QueryState(query, err_sender))?;
|
||||
err_receiver.recv()??;
|
||||
|
||||
Ok(receiver)
|
||||
}
|
||||
|
||||
fn shutdown(self) -> Result<(), Error> {
|
||||
// If the current value is `false`, set it to `true`, otherwise error.
|
||||
if self
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ use crate::service::message::{NodeAnnouncement, RefsAnnouncement};
|
|||
use crate::service::reactor::FetchDirection;
|
||||
use crate::service::tracking::Scope;
|
||||
use crate::storage;
|
||||
use crate::storage::{Inventory, ReadRepository, RefUpdate, WriteStorage};
|
||||
use crate::storage::{Namespaces, ReadStorage};
|
||||
use crate::storage::{ReadRepository, RefUpdate, WriteStorage};
|
||||
use crate::worker::FetchError;
|
||||
use crate::Link;
|
||||
|
||||
|
|
@ -1488,8 +1488,6 @@ where
|
|||
pub trait ServiceState {
|
||||
/// Get the connected peers.
|
||||
fn sessions(&self) -> &Sessions;
|
||||
/// Get the current inventory.
|
||||
fn inventory(&self) -> Result<Inventory, storage::Error>;
|
||||
/// Get a repository from storage, using the local node's key.
|
||||
fn get(&self, proj: Id) -> Result<Option<Doc<Verified>>, IdentityError>;
|
||||
/// Get the clock.
|
||||
|
|
@ -1512,10 +1510,6 @@ where
|
|||
&self.sessions
|
||||
}
|
||||
|
||||
fn inventory(&self) -> Result<Inventory, storage::Error> {
|
||||
self.storage.inventory()
|
||||
}
|
||||
|
||||
fn get(&self, proj: Id) -> Result<Option<Doc<Verified>>, IdentityError> {
|
||||
self.storage.get(&self.node_id(), proj)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
use std::collections::HashSet;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use crossbeam_channel as chan;
|
||||
|
||||
use crate::identity::Id;
|
||||
use crate::node::{FetchResult, Seeds};
|
||||
use crate::runtime::HandleError;
|
||||
|
|
@ -71,10 +69,6 @@ impl radicle::node::Handle for Handle {
|
|||
unimplemented!();
|
||||
}
|
||||
|
||||
fn inventory(&self) -> Result<chan::Receiver<Id>, Self::Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn shutdown(self) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use crate::service::reactor::Io;
|
|||
use crate::service::tracking::{Policy, Scope};
|
||||
use crate::service::*;
|
||||
use crate::storage::git::transport::remote;
|
||||
use crate::storage::Inventory;
|
||||
use crate::storage::{RemoteId, WriteStorage};
|
||||
use crate::test::arbitrary;
|
||||
use crate::test::assert_matches;
|
||||
|
|
@ -194,6 +195,10 @@ where
|
|||
self.clock().as_millis()
|
||||
}
|
||||
|
||||
pub fn inventory(&self) -> Inventory {
|
||||
self.service.storage().inventory().unwrap()
|
||||
}
|
||||
|
||||
pub fn git_url(&self, repo: Id, namespace: Option<RemoteId>) -> remote::Url {
|
||||
remote::Url {
|
||||
node: self.node_id(),
|
||||
|
|
|
|||
|
|
@ -563,7 +563,7 @@ fn test_refs_announcement_relay() {
|
|||
},
|
||||
)
|
||||
};
|
||||
let bob_inv = bob.inventory().unwrap();
|
||||
let bob_inv = bob.storage().inventory().unwrap();
|
||||
|
||||
alice.track_repo(&bob_inv[0], tracking::Scope::All).unwrap();
|
||||
alice.track_repo(&bob_inv[1], tracking::Scope::All).unwrap();
|
||||
|
|
|
|||
|
|
@ -153,8 +153,8 @@ fn test_replication() {
|
|||
alice.connect(&bob);
|
||||
converge([&alice, &bob]);
|
||||
|
||||
let inventory = alice.handle.inventory().unwrap();
|
||||
assert!(inventory.try_iter().next().is_none());
|
||||
let inventory = alice.storage.inventory().unwrap();
|
||||
assert!(inventory.is_empty());
|
||||
|
||||
let tracked = alice.handle.track_repo(acme, Scope::All).unwrap();
|
||||
assert!(tracked);
|
||||
|
|
@ -175,7 +175,7 @@ fn test_replication() {
|
|||
|
||||
log::debug!(target: "test", "Fetch complete with {}", bob.id);
|
||||
|
||||
let inventory = alice.handle.inventory().unwrap();
|
||||
let inventory = alice.storage.inventory().unwrap();
|
||||
let alice_repo = alice.storage.repository(acme).unwrap();
|
||||
let bob_repo = bob.storage.repository(acme).unwrap();
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ fn test_replication() {
|
|||
.collect::<Result<Vec<_>, _>>()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(inventory.try_iter().next(), Some(acme));
|
||||
assert_eq!(inventory.first(), Some(&acme));
|
||||
assert_eq!(alice_refs, bob_refs);
|
||||
assert_matches!(alice.storage.repository(acme).unwrap().verify(), Ok(()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ use std::path::{Path, PathBuf};
|
|||
use std::{fmt, io, net};
|
||||
|
||||
use amplify::WrapperMut;
|
||||
use crossbeam_channel as chan;
|
||||
use cyphernet::addr::{HostName, NetAddr};
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
@ -139,8 +138,6 @@ pub enum CommandName {
|
|||
TrackNode,
|
||||
/// Untrack the given node.
|
||||
UntrackNode,
|
||||
/// Get the node's inventory.
|
||||
Inventory,
|
||||
/// Get the node's status.
|
||||
Status,
|
||||
/// Shutdown the node.
|
||||
|
|
@ -410,8 +407,6 @@ pub trait Handle {
|
|||
fn shutdown(self) -> Result<(), Self::Error>;
|
||||
/// Query the peer session state.
|
||||
fn sessions(&self) -> Result<Self::Sessions, Self::Error>;
|
||||
/// Query the inventory.
|
||||
fn inventory(&self) -> Result<chan::Receiver<Id>, Self::Error>;
|
||||
}
|
||||
|
||||
/// Public node & device identifier.
|
||||
|
|
@ -570,10 +565,6 @@ impl Handle for Node {
|
|||
todo!();
|
||||
}
|
||||
|
||||
fn inventory(&self) -> Result<chan::Receiver<Id>, Error> {
|
||||
todo!();
|
||||
}
|
||||
|
||||
fn shutdown(self) -> Result<(), Error> {
|
||||
todo!();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue