Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
node: Introduce Announcers
Draft lorenz opened 6 months ago

Further decoupling user and node, as a follow up to

patch/05db4d7284c69875986a30b8161238b607155f5e

make the list of “announcers”, i.e. the namespaces that are commonly announced from the node, and for which sync status should be tracked, configurable.

3 files changed +16 -6 d9915d27 06a3a8af
modified crates/radicle-protocol/src/service.rs
@@ -543,7 +543,7 @@ where
    G: crypto::signature::Signer<crypto::Signature>,
{
    pub fn new(
-
        config: Config,
+
        mut config: Config,
        db: Stores<D>,
        storage: S,
        policies: policy::Config<Write>,
@@ -566,6 +566,10 @@ where
                .with_max_capacity(fetcher::MaxQueueSize::default());
            FetcherService::new(config)
        };
+

+
        // For backwards compatibility, ensure that we are announcer of our own Node ID.
+
        config.announcers.insert(*signer.public_key());
+

        Self {
            config,
            storage,
@@ -1593,12 +1597,15 @@ where
                // from a new repository being initialized.
                self.seed_discovered(message.rid, *announcer, message.timestamp);

-
                // Update sync status of announcer for this repo.
-
                if let Some(refs) = refs.iter().find(|r| &r.remote == self.nid()) {
+
                // Update sync status of announcers for this repo.
+
                for refs in refs
+
                    .iter()
+
                    .filter(|r| self.config.announcers.contains(&r.remote))
+
                {
                    debug!(
                        target: "service",
-
                        "Refs announcement of {announcer} for {} contains our own remote at {} (t={})",
-
                        message.rid, refs.at, message.timestamp
+
                        "Refs announcement of {announcer} for {} contains announcer {} (t={})",
+
                        message.rid, refs, message.timestamp
                    );
                    match self.db.seeds_mut().synced(
                        &message.rid,
modified crates/radicle-schemars/src/main.rs
@@ -81,7 +81,7 @@ fn print_schema() -> io::Result<()> {

            #[derive(JsonSchema)]
            #[schemars(untagged)]
-
            #[allow(dead_code)]
+
            #[allow(dead_code, clippy::large_enum_variant)]
            enum CommandResult {
                Nid(radicle::node::NodeId),
                Config(Box<radicle::node::Config>),
modified crates/radicle/src/node/config.rs
@@ -523,6 +523,8 @@ pub struct Config {
    /// the environment variable `RAD_PASSPHRASE`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub secret: Option<std::path::PathBuf>,
+
    #[serde(default, skip_serializing_if = "HashSet::is_empty")]
+
    pub announcers: HashSet<super::NodeId>,
}

impl Config {
@@ -551,6 +553,7 @@ impl Config {
            database: node::db::config::Config::default(),
            extra: json::Map::default(),
            secret: None,
+
            announcers: HashSet::new(),
        }
    }