Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: Event on local refs announcement
cloudhead committed 2 years ago
commit 4276a70eb1c719e2c7f26ac4db1f935f5c84c147
parent e5d8563cca462e832f8f14cc59ecd02504501ef2
2 files changed +11 -2
modified radicle-node/src/service.rs
@@ -1892,13 +1892,17 @@ where
    /// Announce our own refs for the given repo.
    fn announce_own_refs(&mut self, rid: RepoId, doc: Doc<Verified>) -> Result<Vec<RefsAt>, Error> {
        let refs = self.announce_refs(rid, doc, [self.node_id()])?;
+
        let now = self.local_time();

        // Update refs database with our signed refs branches.
        // This isn't strictly necessary for now, as we only use the database for fetches, and
        // we don't fetch our own refs that are announced, but it's for good measure.
        if let &[r] = refs.as_slice() {
-
            let now = self.local_time();
-

+
            self.emitter.emit(Event::LocalRefsAnnounced {
+
                rid,
+
                refs: r,
+
                timestamp: now.as_millis(),
+
            });
            if let Err(e) =
                self.database_mut()
                    .refs_mut()
modified radicle/src/node/events.rs
@@ -37,6 +37,11 @@ pub enum Event {
        nid: NodeId,
        reason: String,
    },
+
    LocalRefsAnnounced {
+
        rid: RepoId,
+
        refs: refs::RefsAt,
+
        timestamp: Timestamp,
+
    },
    InventoryAnnounced {
        nid: NodeId,
        inventory: Vec<RepoId>,