Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
node: Combine event with sync status change
Browse files Browse the repository at this point in the history
Use the same logic to check whether the sync status was updated, to emit
the `RefsSynced` event. That way they are at least consistent.
  • Loading branch information
cloudhead committed Mar 22, 2024
1 parent 474df7f commit a4928f5
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions radicle-node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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) => {
Expand All @@ -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*,
Expand Down

0 comments on commit a4928f5

Please sign in to comment.