Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: Combine event with sync status change
cloudhead committed 2 years ago
commit a4928f50b6d88495f13ff2d7db3157c920417345
parent 474df7fc3cae93c7a098a3aea592587c6fc345a2
1 file changed +6 -16
modified radicle-node/src/service.rs
@@ -1285,7 +1285,7 @@ where
            match self.db.addresses().get(announcer) {
                Ok(node) => {
                    if node.is_none() {
-
                        trace!(target: "service", "Ignoring announcement from unknown node {announcer}");
+
                        debug!(target: "service", "Ignoring announcement from unknown node {announcer}");
                        return Ok(false);
                    }
                }
@@ -1408,6 +1408,11 @@ where
                                    "Updating sync status of {announcer} for {} to {}",
                                    message.rid, refs.at
                                );
+
                                self.emitter.emit(Event::RefsSynced {
+
                                    rid: message.rid,
+
                                    remote: *announcer,
+
                                    at: refs.at,
+
                                });
                            }
                        }
                        Err(e) => {
@@ -1431,21 +1436,6 @@ where
                            return Ok(relay);
                        }
                    };
-
                    // If the ref announcement indicates that the announcer already has
-
                    // our *owned* refs, then we emit an event, which can be used to
-
                    // show sync status to the user.
-
                    if let Some(at) = stale
-
                        .iter()
-
                        .find(|refs| &refs.remote == self.nid())
-
                        .copied()
-
                        .map(|RefsAt { at, .. }| at)
-
                    {
-
                        self.emitter.emit(Event::RefsSynced {
-
                            rid: message.rid,
-
                            remote: *announcer,
-
                            at,
-
                        });
-
                    }

                    // Refs can be relayed by peers who don't have the data in storage,
                    // therefore we only check whether we are connected to the *announcer*,