Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: use new method instead
Fintan Halpenny committed 7 months ago
commit d0bd3fcc8656d9f18ba102417ce3391bacec83f2
parent 3f47d9f4b2d8312d858476face45f3ca4d563ada
6 files changed +24 -16
modified crates/radicle-cli/tests/commands.rs
@@ -1772,7 +1772,7 @@ fn test_cob_replication() {
    // announcement, otherwise Alice will consider it stale.
    thread::sleep(time::Duration::from_millis(3));

-
    bob.handle.announce_refs(rid, None).unwrap();
+
    bob.handle.announce_refs(rid).unwrap();

    // Wait for Alice to fetch the issue refs.
    events
modified crates/radicle-node/src/control.rs
@@ -219,8 +219,13 @@ where
                return Err(CommandError::Runtime(e));
            }
        },
-
        Command::AnnounceRefs { rid, ns } => {
-
            let refs = handle.announce_refs(rid, ns)?;
+
        Command::AnnounceRefs { rid } => {
+
            let refs = handle.announce_refs(rid)?;
+

+
            CommandResult::Okay(refs).to_writer(writer)?;
+
        }
+
        Command::AnnounceRefsFor { rid, ns } => {
+
            let refs = handle.announce_refs_for(rid, ns)?;

            CommandResult::Okay(refs).to_writer(writer)?;
        }
@@ -291,7 +296,6 @@ fn fetch<W: Write, H: Handle<Error = runtime::HandleError>>(

#[cfg(test)]
mod tests {
-
    use std::collections::HashSet;
    use std::io::prelude::*;
    use std::thread;

@@ -328,7 +332,6 @@ mod tests {
                "{}",
                json::to_string(&Command::AnnounceRefs {
                    rid: rid.to_owned(),
-
                    ns: HashSet::new(),
                })
                .unwrap()
            )
modified crates/radicle-node/src/runtime/handle.rs
@@ -255,7 +255,7 @@ impl radicle::node::Handle for Handle {
        receiver.recv().map_err(Error::from)
    }

-
    fn announce_refs(
+
    fn announce_refs_for(
        &mut self,
        id: RepoId,
        ns: impl IntoIterator<Item = PublicKey>,
modified crates/radicle-node/src/test/handle.rs
@@ -92,7 +92,7 @@ impl radicle::node::Handle for Handle {
        Ok(self.following.lock().unwrap().remove(&id))
    }

-
    fn announce_refs(
+
    fn announce_refs_for(
        &mut self,
        id: RepoId,
        ns: impl IntoIterator<Item = PublicKey>,
modified crates/radicle-node/src/tests/e2e.rs
@@ -1378,7 +1378,7 @@ fn test_background_foreground_fetch() {
        Title::new("Concurrent fetches").unwrap(),
        "Concurrent fetches are harshing my vibes",
    );
-
    bob.handle.announce_refs(rid, None).unwrap();
+
    bob.handle.announce_refs(rid).unwrap();
    alice_events
        .wait(
            |e| matches!(e, Event::RefsAnnounced { .. }).then_some(()),
@@ -1427,7 +1427,7 @@ fn test_catchup_on_refs_announcements() {

    log::debug!(target: "test", "Bob creating his issue..");
    bob.issue(acme, Title::new("Bob's issue").unwrap(), "[..]");
-
    bob.handle.announce_refs(acme, None).unwrap();
+
    bob.handle.announce_refs(acme).unwrap();

    log::debug!(target: "test", "Waiting for seed to fetch Bob's refs from Bob..");
    seed.has_remote_of(&acme, &bob.id); // Seed fetches Bob's refs.
modified crates/radicle/src/node.rs
@@ -613,10 +613,11 @@ impl From<Address> for HostName {
#[serde(rename_all = "camelCase", tag = "command")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum Command {
-
    /// Announce repository references for given repository
-
    /// and namespaces to peers.
+
    /// Announce repository references for given repository and local node.
    #[serde(rename_all = "camelCase")]
-
    AnnounceRefs {
+
    AnnounceRefs { rid: RepoId },
+

+
    AnnounceRefsFor {
        rid: RepoId,

        /// The namespaces for which references should be announced.
@@ -1132,7 +1133,11 @@ pub trait Handle: Clone + Sync + Send {
    /// Unfollow the given peer.
    fn unfollow(&mut self, id: NodeId) -> Result<bool, Self::Error>;
    /// Notify the service that a project has been updated, and announce local refs.
-
    fn announce_refs(
+
    fn announce_refs(&mut self, id: RepoId) -> Result<RefsAt, Self::Error> {
+
        self.announce_refs_for(id, [self.nid()?])
+
    }
+
    /// Notify the service that a project has been updated for a number namespaces.
+
    fn announce_refs_for(
        &mut self,
        id: RepoId,
        ns: impl IntoIterator<Item = PublicKey>,
@@ -1244,7 +1249,7 @@ impl Node {
        mut report: impl FnMut(&NodeId, sync::announce::Progress),
    ) -> Result<sync::AnnouncerResult, Error> {
        let mut events = self.subscribe(timeout)?;
-
        let refs = self.announce_refs(rid, ns)?;
+
        let refs = self.announce_refs_for(rid, ns)?;

        let started = time::Instant::now();

@@ -1415,14 +1420,14 @@ impl Handle for Node {
        Ok(response.updated)
    }

-
    fn announce_refs(
+
    fn announce_refs_for(
        &mut self,
        rid: RepoId,
        ns: impl IntoIterator<Item = PublicKey>,
    ) -> Result<RefsAt, Error> {
        let refs: RefsAt = self
            .call(
-
                Command::AnnounceRefs {
+
                Command::AnnounceRefsFor {
                    rid,
                    ns: HashSet::from_iter(ns),
                },