diff --git a/radicle-cli/src/commands/node/tracking.rs b/radicle-cli/src/commands/node/tracking.rs index ca414438..cee85dce 100644 --- a/radicle-cli/src/commands/node/tracking.rs +++ b/radicle-cli/src/commands/node/tracking.rs @@ -18,7 +18,7 @@ fn print_repos(node: &Node) -> anyhow::Result<()> { let mut t = term::Table::new(term::table::TableOptions::default()); t.push(["RID", "Scope", "Policy"]); t.push(["---", "-----", "------"]); - for tracking::Repo { id, scope, policy } in node.tracked_repos()? { + for tracking::Repo { id, scope, policy } in node.repo_policies()? { t.push([ term::format::highlight(id.to_string()), term::format::secondary(scope.to_string()), @@ -33,7 +33,7 @@ fn print_nodes(node: &Node) -> anyhow::Result<()> { let mut t = term::Table::new(term::table::TableOptions::default()); t.push(["DID", "Alias", "Policy"]); t.push(["---", "-----", "------"]); - for tracking::Node { id, alias, policy } in node.tracked_nodes()? { + for tracking::Node { id, alias, policy } in node.node_policies()? { t.push([ term::format::highlight(Did::from(id).to_string()), match alias { diff --git a/radicle-node/src/control.rs b/radicle-node/src/control.rs index 74585a91..2643e560 100644 --- a/radicle-node/src/control.rs +++ b/radicle-node/src/control.rs @@ -131,7 +131,7 @@ fn command>( } } } - CommandName::TrackedRepos => match handle.tracked_repos() { + CommandName::RepoPolicies => match handle.repo_policies() { Ok(ts) => { for t in ts.into_iter() { serde_json::to_writer(&mut writer, &t)?; @@ -171,7 +171,7 @@ fn command>( } } } - CommandName::TrackedNodes => match handle.tracked_nodes() { + CommandName::NodePolicies => match handle.node_policies() { Ok(ts) => { for t in ts.into_iter() { serde_json::to_writer(&mut writer, &t)?; diff --git a/radicle-node/src/runtime/handle.rs b/radicle-node/src/runtime/handle.rs index 820bdd93..2c2205d8 100644 --- a/radicle-node/src/runtime/handle.rs +++ b/radicle-node/src/runtime/handle.rs @@ -111,8 +111,8 @@ impl radicle::node::Handle for Handle { type Error = Error; type Routing = chan::Receiver<(Id, NodeId)>; - type TrackedRepos = chan::Receiver; - type TrackedNodes = chan::Receiver; + type RepoPolicies = chan::Receiver; + type NodePolicies = chan::Receiver; fn is_running(&self) -> bool { true @@ -136,10 +136,10 @@ impl radicle::node::Handle for Handle { receiver.recv().map_err(Error::from) } - fn tracked_repos(&self) -> Result { + fn repo_policies(&self) -> Result { let (sender, receiver) = chan::unbounded(); let query: Arc = Arc::new(move |state| { - for t in state.tracked_repos()? { + for t in state.repo_policies()? { if sender.send(t).is_err() { break; } @@ -153,10 +153,10 @@ impl radicle::node::Handle for Handle { Ok(receiver) } - fn tracked_nodes(&self) -> Result { + fn node_policies(&self) -> Result { let (sender, receiver) = chan::unbounded(); let query: Arc = Arc::new(move |state| { - for t in state.tracked_nodes()? { + for t in state.node_policies()? { if sender.send(t).is_err() { break; } diff --git a/radicle-node/src/service.rs b/radicle-node/src/service.rs index 26fe76c0..27f8e902 100644 --- a/radicle-node/src/service.rs +++ b/radicle-node/src/service.rs @@ -1452,9 +1452,9 @@ pub trait ServiceState { /// Get reference to routing table. fn routing(&self) -> &dyn routing::Store; /// Get the tracked repos. - fn tracked_repos(&self) -> Result, tracking::Error>; + fn repo_policies(&self) -> Result, tracking::Error>; /// Get the tracked nodes. - fn tracked_nodes(&self) -> Result, tracking::Error>; + fn node_policies(&self) -> Result, tracking::Error>; } impl ServiceState for Service @@ -1491,11 +1491,11 @@ where &self.routing } - fn tracked_repos(&self) -> Result, tracking::Error> { + fn repo_policies(&self) -> Result, tracking::Error> { Ok(self.tracking.repo_entries()?.collect()) } - fn tracked_nodes(&self) -> Result, tracking::Error> { + fn node_policies(&self) -> Result, tracking::Error> { Ok(self.tracking.node_entries()?.collect()) } } diff --git a/radicle-node/src/test/handle.rs b/radicle-node/src/test/handle.rs index d163e7cd..07efa209 100644 --- a/radicle-node/src/test/handle.rs +++ b/radicle-node/src/test/handle.rs @@ -21,8 +21,8 @@ impl radicle::node::Handle for Handle { type Error = HandleError; type Sessions = service::Sessions; type Routing = Vec<(Id, NodeId)>; - type TrackedRepos = Vec; - type TrackedNodes = Vec; + type RepoPolicies = Vec; + type NodePolicies = Vec; fn is_running(&self) -> bool { true @@ -40,7 +40,7 @@ impl radicle::node::Handle for Handle { Ok(FetchResult::from(Ok::, Self::Error>(vec![]))) } - fn tracked_repos(&self) -> Result { + fn repo_policies(&self) -> Result { Ok(self .tracking_repos .iter() @@ -53,7 +53,7 @@ impl radicle::node::Handle for Handle { .collect()) } - fn tracked_nodes(&self) -> Result { + fn node_policies(&self) -> Result { Ok(self .tracking_nodes .iter() diff --git a/radicle/src/node.rs b/radicle/src/node.rs index f60965f8..00aa6438 100644 --- a/radicle/src/node.rs +++ b/radicle/src/node.rs @@ -125,14 +125,14 @@ pub enum CommandName { TrackRepo, /// Untrack the given repository. UntrackRepo, - /// Get the tracked repositories. - TrackedRepos, + /// Get the repository tracking policies. + RepoPolicies, /// Track the given node. TrackNode, /// Untrack the given node. UntrackNode, - /// Get the tracked nodes. - TrackedNodes, + /// Get the node tracking policies. + NodePolicies, /// Get the node's inventory. Inventory, /// Get the node's routing table. @@ -380,8 +380,8 @@ pub trait Handle { type Error: std::error::Error + Send + Sync + 'static; type Routing: IntoIterator; - type TrackedRepos: IntoIterator; - type TrackedNodes: IntoIterator; + type RepoPolicies: IntoIterator; + type NodePolicies: IntoIterator; /// Check if the node is running. to a peer. fn is_running(&self) -> bool; @@ -400,10 +400,10 @@ pub trait Handle { fn untrack_repo(&mut self, id: Id) -> Result; /// Untrack the given node. fn untrack_node(&mut self, id: NodeId) -> Result; - /// Get the tracking information for all tracked repos in storage. - fn tracked_repos(&self) -> Result; - /// Get the tracking information for all tracked nodes in storage. - fn tracked_nodes(&self) -> Result; + /// Get the tracking information for all tracked or blocked repos in storage. + fn repo_policies(&self) -> Result; + /// Get the tracking information for all tracked or blocked nodes in storage. + fn node_policies(&self) -> Result; /// Notify the service that a project has been updated, and announce local refs. fn announce_refs(&mut self, id: Id) -> Result<(), Self::Error>; /// Announce local inventory. @@ -459,14 +459,14 @@ impl Node { } } -// TODO(finto): tracked_repos, tracked_nodes, and routing should all +// TODO(finto): repo_policies, node_policies, and routing should all // attempt to return iterators instead of allocating vecs. impl Handle for Node { type Sessions = (); type Error = Error; - type TrackedRepos = Vec; - type TrackedNodes = Vec; + type RepoPolicies = Vec; + type NodePolicies = Vec; type Routing = Vec<(Id, NodeId)>; fn is_running(&self) -> bool { @@ -510,18 +510,18 @@ impl Handle for Node { Ok(result) } - fn tracked_repos(&self) -> Result, Self::Error> { + fn repo_policies(&self) -> Result, Self::Error> { let mut repos = Vec::new(); - for result in self.call::<&str, _>(CommandName::TrackedRepos, [])? { + for result in self.call::<&str, _>(CommandName::RepoPolicies, [])? { let repo = result?; repos.push(repo); } Ok(repos) } - fn tracked_nodes(&self) -> Result, Self::Error> { + fn node_policies(&self) -> Result, Self::Error> { let mut repos = Vec::new(); - for result in self.call::<&str, _>(CommandName::TrackedNodes, [])? { + for result in self.call::<&str, _>(CommandName::NodePolicies, [])? { let repo = result?; repos.push(repo); }