From 6ff4efebedd046a59b385d70f34d153bcd3acb57 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Thu, 4 Apr 2024 18:22:19 +0200 Subject: [PATCH] node: Remove namespaces from fetch request It was unused.. --- radicle-node/src/service.rs | 5 +---- radicle-node/src/service/io.rs | 5 ----- radicle-node/src/test/peer.rs | 14 ++++---------- radicle-node/src/test/simulator.rs | 12 ++---------- radicle-node/src/tests.rs | 14 +++++++------- radicle-node/src/wire/protocol.rs | 1 - 6 files changed, 14 insertions(+), 37 deletions(-) diff --git a/radicle-node/src/service.rs b/radicle-node/src/service.rs index f05d50fe..f86ac835 100644 --- a/radicle-node/src/service.rs +++ b/radicle-node/src/service.rs @@ -963,10 +963,7 @@ where refs_at: refs_at.clone(), subscribers: vec![], }); - let namespaces = self.policies.namespaces_for(&self.storage, &rid)?; - - self.outbox - .fetch(session, rid, namespaces, refs_at, timeout); + self.outbox.fetch(session, rid, refs_at, timeout); debug!( target: "service", diff --git a/radicle-node/src/service/io.rs b/radicle-node/src/service/io.rs index fad25e0a..ba01d190 100644 --- a/radicle-node/src/service/io.rs +++ b/radicle-node/src/service/io.rs @@ -7,7 +7,6 @@ use radicle::storage::refs::RefsAt; use crate::prelude::*; use crate::service::session::Session; use crate::service::Link; -use crate::storage::Namespaces; use super::gossip; use super::message::{Announcement, AnnouncementMessage}; @@ -27,8 +26,6 @@ pub enum Io { rid: RepoId, /// Remote node being fetched from. remote: NodeId, - /// Namespaces being fetched. - namespaces: Namespaces, /// If the node is fetching specific `rad/sigrefs`. refs_at: Option>, /// Fetch timeout. @@ -125,7 +122,6 @@ impl Outbox { &mut self, remote: &mut Session, rid: RepoId, - namespaces: Namespaces, refs_at: Vec, timeout: time::Duration, ) { @@ -134,7 +130,6 @@ impl Outbox { let refs_at = (!refs_at.is_empty()).then_some(refs_at); self.io.push_back(Io::Fetch { rid, - namespaces, refs_at, remote: remote.id, timeout, diff --git a/radicle-node/src/test/peer.rs b/radicle-node/src/test/peer.rs index 82b02ba6..e8b2455a 100644 --- a/radicle-node/src/test/peer.rs +++ b/radicle-node/src/test/peer.rs @@ -28,7 +28,7 @@ use crate::service::policy::{Policy, Scope}; use crate::service::*; use crate::storage::git::transport::remote; use crate::storage::Inventory; -use crate::storage::{Namespaces, RemoteId, WriteStorage}; +use crate::storage::{RemoteId, WriteStorage}; use crate::test::storage::MockStorage; use crate::test::{arbitrary, fixtures, simulator}; use crate::wire::MessageType; @@ -476,16 +476,10 @@ where } /// Get a draining iterator over the peer's I/O outbox, which only returns fetches. - pub fn fetches(&mut self) -> impl Iterator + '_ { + pub fn fetches(&mut self) -> impl Iterator + '_ { iter::from_fn(|| self.service.outbox().next()).filter_map(|io| { - if let Io::Fetch { - rid, - remote, - namespaces, - .. - } = io - { - Some((rid, remote, namespaces)) + if let Io::Fetch { rid, remote, .. } = io { + Some((rid, remote)) } else { None } diff --git a/radicle-node/src/test/simulator.rs b/radicle-node/src/test/simulator.rs index 98c94381..61fca608 100644 --- a/radicle-node/src/test/simulator.rs +++ b/radicle-node/src/test/simulator.rs @@ -627,12 +627,7 @@ impl Simulation { ); } } - Io::Fetch { - rid, - remote, - namespaces, - .. - } => { + Io::Fetch { rid, remote, .. } => { log::info!( target: "sim", "{:05} {} ~> {} ({}): Fetch outgoing", @@ -663,10 +658,7 @@ impl Simulation { remote, Rc::new(Ok(fetch::FetchResult { updated: vec![], - namespaces: match namespaces { - Namespaces::Followed(hs) => hs, - Namespaces::All => HashSet::new(), - }, + namespaces: HashSet::new(), clone: true, doc: arbitrary::gen(1), })), diff --git a/radicle-node/src/tests.rs b/radicle-node/src/tests.rs index 90a11bde..5e10c7bd 100644 --- a/radicle-node/src/tests.rs +++ b/radicle-node/src/tests.rs @@ -1365,7 +1365,7 @@ fn test_queued_fetch_max_capacity() { alice.command(Command::Fetch(rid3, bob.id, DEFAULT_TIMEOUT, send3)); // The first fetch is initiated. - assert_matches!(alice.fetches().next(), Some((rid, _, _)) if rid == rid1); + assert_matches!(alice.fetches().next(), Some((rid, _)) if rid == rid1); // We shouldn't send out the 2nd, 3rd fetch while we're doing the 1st fetch. assert_matches!(alice.outbox().next(), None); @@ -1375,14 +1375,14 @@ fn test_queued_fetch_max_capacity() { // Finish the 1st fetch. alice.fetched(rid1, bob.id, Ok(fetch::FetchResult::new(doc.clone()))); // Now the 1st fetch is done, the 2nd fetch is dequeued. - assert_matches!(alice.fetches().next(), Some((rid, _, _)) if rid == rid2); + assert_matches!(alice.fetches().next(), Some((rid, _)) if rid == rid2); // ... but not the third. assert_matches!(alice.fetches().next(), None); // Finish the 2nd fetch. alice.fetched(rid2, bob.id, Ok(fetch::FetchResult::new(doc))); // Now the 2nd fetch is done, the 3rd fetch is dequeued. - assert_matches!(alice.fetches().next(), Some((rid, _, _)) if rid == rid3); + assert_matches!(alice.fetches().next(), Some((rid, _)) if rid == rid3); } #[test] @@ -1421,7 +1421,7 @@ fn test_queued_fetch_from_ann_same_rid() { alice.receive(carol.id, carol.announcement(ann)); // The first fetch is initiated. - assert_matches!(alice.fetches().next(), Some((rid_, nid_, _)) if rid_ == rid && nid_ == bob.id); + assert_matches!(alice.fetches().next(), Some((rid_, nid_)) if rid_ == rid && nid_ == bob.id); // We shouldn't send out the 2nd, 3rd fetch while we're doing the 1st fetch. assert_matches!(alice.fetches().next(), None); @@ -1490,7 +1490,7 @@ fn test_queued_fetch_from_command_same_rid() { alice.command(Command::Fetch(rid1, carol.id, DEFAULT_TIMEOUT, send3)); // The first fetch is initiated. - assert_matches!(alice.fetches().next(), Some((rid, nid, _)) if rid == rid1 && nid == bob.id); + assert_matches!(alice.fetches().next(), Some((rid, nid)) if rid == rid1 && nid == bob.id); // We shouldn't send out the 2nd, 3rd fetch while we're doing the 1st fetch. assert_matches!(alice.outbox().next(), None); @@ -1500,14 +1500,14 @@ fn test_queued_fetch_from_command_same_rid() { // Finish the 1st fetch. alice.fetched(rid1, bob.id, Ok(arbitrary::gen::(1))); // Now the 1st fetch is done, the 2nd fetch is dequeued. - assert_matches!(alice.fetches().next(), Some((rid, nid, _)) if rid == rid1 && nid == eve.id); + assert_matches!(alice.fetches().next(), Some((rid, nid)) if rid == rid1 && nid == eve.id); // ... but not the third. assert_matches!(alice.fetches().next(), None); // Finish the 2nd fetch. alice.fetched(rid1, eve.id, Ok(arbitrary::gen::(1))); // Now the 2nd fetch is done, the 3rd fetch is dequeued. - assert_matches!(alice.fetches().next(), Some((rid, nid, _)) if rid == rid1 && nid == carol.id); + assert_matches!(alice.fetches().next(), Some((rid, nid)) if rid == rid1 && nid == carol.id); } #[test] diff --git a/radicle-node/src/wire/protocol.rs b/radicle-node/src/wire/protocol.rs index 2cb63e2b..7d4e113a 100644 --- a/radicle-node/src/wire/protocol.rs +++ b/radicle-node/src/wire/protocol.rs @@ -964,7 +964,6 @@ where remote, timeout, refs_at, - .. } => { log::trace!(target: "wire", "Processing fetch for {rid} from {remote}..");