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